I have the following macro:
#define FIELD_ACCESSOR_FUNCTIONS(typeName, fieldAccessorNamePrefix) \
JNIEXPORT jobject JNICALL my_pckg_NativeExecutor_get ## typeName ## FieldValue(JNIEnv* jNIEnv, jobject nativeExecutorInstance, jobject target, jobject field) { \
return environment-> ## fieldAccessorNamePrefix ## FieldAccessor->getValue(jNIEnv, target, field); \
}
FIELD_ACCESSOR_FUNCTIONS(Object, object)
And when I start the compilation I get the following error:
NativeExecutor.cpp:59:20: error: pasting "->" and "object" does not give a valid preprocessing token
return environment-> ## fieldAccessorNamePrefix ## FieldAccessor->getValue(jNIEnv, target, field); \
^~
How can I solve?
CodePudding user response:
Drop the first ##
. The name you are trying to generate is fieldAccessorNamePrefix ## FieldAccessor
. The ->
must not be part of the token.