Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event export macro #1243

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Event export macro #1243

wants to merge 5 commits into from

Conversation

matcool
Copy link
Member

@matcool matcool commented Feb 18, 2025

Example Usage:

// (In your api distributed header file)
#pragma once
#include <Geode/loader/Dispatch.hpp>
// You must **manually** declare the mod id, as macros like GEODE_MOD_ID will not
// behave correctly to other mods using your api.
#define MY_MOD_ID "dev.my-api"

namespace api {
  // Important: The function must be declared inline, and return a geode::Result,
  // as it can fail if the api is not available.
  inline geode::Result<int> addNumbers(int a, int b) GEODE_EVENT_EXPORT(&addNumbers, (a, b));
}

Then, in one of your source files, you must define the exported functions:

// MUST be defined before including the header.
#define GEODE_DEFINE_EVENT_EXPORTS
#include "../include/api.hpp"
Result<int> api::addNumbers(int a, int b) {
  return Ok(a + b);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants