#define JNI_DECLARE( classname, methodname ) \
classname ## methodname( JNI* env )
#define JAVA_CLASS Java_com_example
void JNI_DECLARE( JAVA_CLASS, open ) {}
This expands to:
void JAVA_CLASS_open( JNI* env ) {}
How do I get:
void Java_com_example_open( JNI* env ) {}
?
Concatenation means joining two strings into one. In the context of macro expansion, concatenation refers to joining two lexical units into one longer one. Specifically, an actual argument to the macro can be concatenated with another actual argument or with fixed text to produce a longer name.
Macro expansion is an integral part of eval and compile . Users can also expand macros at the REPL prompt via the expand REPL command; See Compile Commands. Macros can also be expanded programmatically, via macroexpand , but the details get a bit hairy for two reasons. The second complication involves eval-when .
The double-number-sign or token-pasting operator (##), which is sometimes called the merging or combining operator, is used in both object-like and function-like macros. It permits separate tokens to be joined into a single token, and therefore, can't be the first or last token in the macro definition.
The number-sign or "stringizing" operator (#) converts macro parameters to string literals without expanding the parameter definition. It's used only with macros that take arguments.
#define JNI_DECLARE_INNER( classname, methodname ) \
classname ## _ ## methodname( JNI* env )
#define JNI_DECLARE( classname, methodname ) \
JNI_DECLARE_INNER(classname, methodname)
see more here: C Preprocessor, Stringify the result of a macro
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With