-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
meta: dealing with language differences between C++ and nim #18
Comments
Const is a huge PITA - I dynlib deals with the inconsistencies by generating code like (it just ignores typedef N_CDECL_PTR(NCSTRING, tyProc__cTCodr69cPNr9chtH7apXJYg) (NCSTRING s);
Dl_4294968796_ = (tyProc__cTCodr69cPNr9chtH7apXJYg) nimGetProcAddr(TM__xDZurH9b9cD5SoY3HyXHwqcw_2, "wave_unescapeIncludeToken"); and then calling it, but if I try to do a simple
|
const
h = "lib.h"
l = "liblib.so"
type
str {.importc: "struct str", header: h.} = object
field: cint
echo str()
proc get_cstring_dl(str: cstring) {.dynlib: l, importc: "get_cstring_dl".}
get_cstring_dl(nil)
proc get_cstring_link(str: cstring) {.cdecl, importc: "get_cstring_link".}
get_cstring_link(nil)
target("lib")
set_kind("shared")
add_files("lib.c")
set_targetdir(os.scriptdir())
target("main")
set_kind("binary")
add_deps("lib")
add_files("nim_cxx_const_main.nim")
add_links("lib")
set_targetdir(os.scriptdir())
void get_cstring(const char* cstring) {}
void get_cstring_link(const char* cstring) {}
struct str {
int field;
};
void get_cstring_dl(const char* cstring);
void get_cstring_link(const char* cstring); Reproduce with
|
I think this could've been trivially solved if
Can this be fixed by making |
I can wrap each type twice - as a regular object and as a |
ccstring
(const char*) fromcmstring
(char*
) timotheecour/Nim#524method
for wrapping C++ methods #1 and Overriding C++ clases on the nim side (current best implementation idea) #2 very hard to properly interface with Cxx classes. Numerous workarounds can be implemented, but all of them have limitationsAdditional related links
The text was updated successfully, but these errors were encountered: