https://kotlinlang.org logo
x

xiaobailong24

08/12/2022, 7:47 AM
Hi, folks. I want to call a
#define FUNCTION()
in objc header file from kotlin code, how should i do to cinterop it to kotlin klib?
Copy code
#define RCT_EXPORT_MODULE(js_name) \
RCT_EXTERN void RCTRegisterModule(Class); \
+ (NSString *)moduleName{ return @#js_name; } \
+ (void)mrn_moduleRegister {  \
KLN_METHODS_EXPORT(kMRNReactNativeModuleRegisterKey);  \
RCTRegisterModule(self);  \
}
.def looks like:
Copy code
language = Objective-C
headers = RCTBridgeModule.h RCTBridge.h
headerFilter = RCTBridgeModule.h RCTBridge.h

---

static inline void rctExportModule(NSString* str) {
    RCT_EXPORT_MODULE(str);
}
Then got this error:
Copy code
Exception in thread "main" java.lang.Error: /var/folders/r1/ph4mc_993nqbc_v5m82d0rv80000gp/T/8166082263048599838.m:5:5: error: use of undeclared identifier 'moduleName'
	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:273)
	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1189)
	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1178)
	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1174)
	at org.jetbrains.kotlin.native.interop.gen.jvm.DefaultPlugin.buildNativeIndex(Plugins.kt:33)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:272)
	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
10 Views