Skip to content

Allow extern mode for redismodule.h #6330

Closed
mnunberg wants to merge 2 commits intoredis:unstablefrom
mnunberg:unstable
Closed

Allow extern mode for redismodule.h #6330
mnunberg wants to merge 2 commits intoredis:unstablefrom
mnunberg:unstable

Conversation

@mnunberg
Copy link
Contributor

No description provided.

This fixes the redismodule.h file to use proper extern semantics, where
symbols are only declared in the header file, but defined in a source
file elsewhere. This functionality is by default disabled unless the
symbol `REDISMODULE_USE_EXTERN` is defined in the preprocessor.

When `REDISMODULE_USE_EXTERN` is defined, the `RedisModule_XXX`
functions are declared as `extern`, meaning they are simply declarations
for the function pointers. The user needs to define them somewhere else,
using the `REDISMODULE_INIT_SYMBOLS()` macro. This should be done once
and only once, in a source file, for the entire executable or library.
This confuses C++ applications
@mnunberg
Copy link
Contributor Author

@swilly22 @MeirShpilraien fyi

@mnunberg
Copy link
Contributor Author

@oranagra

@rafie
Copy link
Contributor

rafie commented Sep 26, 2019

The version here: https://github.com/RedisLabs/RedisModulesSDK/blob/rafi-modsdk1/redismodule.h
is a bit more compact, and also includes REDISMODULE_XAPI_EXTENSIONS macro that allows extending the API.

rafie added a commit to rafie/redis that referenced this pull request Nov 20, 2019
* Introduced REDISMODULE_INIT_SYMBOLS macro, to allow including redismodule.h in several source files (this is a breaking change)
* Avoid double-mentions of APIs by using X-macro
* Support inclusion from C++ sources

See also redis#6330
rafie added a commit to rafie/redis that referenced this pull request Nov 22, 2019
* Introduced REDISMODULE_INIT_SYMBOLS macro, to allow including redismodule.h in several source files (this is a breaking change)
* Avoid double-mentions of APIs by using X-macro
* Support inclusion from C++ sources

See also redis#6330
rafie added a commit to rafie/redis that referenced this pull request Nov 28, 2019
* Allow including redismodule.h in several source files, by declaring API function vars weak [i.e., __attribute__ ((weak))].
* Avoid double-mentions of APIs by using X-macro acrobatics
* Allow for API extensions via REDISMODULE_XAPI_EXTENSIONS macro
* Removed explicit REGISTER_API-s from module.c
* Support inclusion from C++ sources

See also redis#6330
@oranagra
Copy link
Member

oranagra commented Aug 8, 2020

Closing this one in favor of #6900. If you can, please test the changes in that PR and acknowledge that they indeed solve the problem. please post feedback in #6900.

@oranagra oranagra closed this Aug 8, 2020
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.

4 participants