Hi,
I'm getting "SIGSEGV: Illegal storage access. (Attempt to read from nil?)" errors when passing a cstring to a wrapped library function.
when defined(windows): const Lib = "XPLM_64.dll" elif defined(macosx): const Lib = "XPLM_64.dylib" else: const Lib = "XPLM_64.so" # XPLMDebugString # # This routine outputs a C-style string to the Log.txt file. The file is # immediately flushed so you will not lose data. (This does cause a # performance penalty.) # # XPLM_API void XPLMDebugString(const char* inString); # proc XPLMDebugString*(inString: cstring) {.cdecl, importc: "XPLMDebugString", dynlib: Lib}
Example code:
var starup_msg: cstring = "CommViewer Plugin: startup completed\n" XPLMDebugString(starup_msg) # <- this causes the Illegal storage access error
I'm using Nim Compiler Version 0.10.1 (2014-12-27) [Linux: amd64]
thanks, joe
My plugin wrapper was using a copy of the app's plugin, XPLM_64.so,
I'd (temporarily) copied to /usr/lib whereas the app was using its
own copy of the plugin it had in a sub-directory. Once I deleted
the plugin from /usr/lib and added the apps plugin path to
LD_LIBRARY_PATH it worked.