-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Returning null instead of empty string if a wrapped function returns null pointer #22574
Comments
That sounds like the correct behaviour yes. Would you have time to send a PR? I think the code in question is in |
Actually it looks like there is already handling for this case: emscripten/src/library_ccall.js Lines 33 to 38 in 645750c
It looks like it should return 0 if getLastError returns NULL/0. |
Sorry thats the handler to argument. The handler for returned strings just calls emscripten/src/library_strings.js Line 126 in 645750c
I wonder how much stuff would break if we changed that to return |
Thanks for responding so quickly, Sam, I really appreciate it. I agree that changing the behavior of I was primarily wondering if this is a conscious design choice or just something that turned out the way it is for reasons unknown. |
I think this is likely an historcal accident. |
I agree changing this is probably not worth it. I'm not sure why it is the way it is, but likely the early users of the function preferred it that way, or it didn't matter. |
I'd still like to try and make this change if we can.. not sure if there is way to do it in a backwards compatible way.. |
Hi emscripten folks,
I am trying to wrap a function with the following C signature:
It returns a pointer to zero-terminated C string or the NULL pointer in case no last error exists.
Wrapping the function in emscripten using
Module.cwrap('getLastError', 'string', [])
yields a function that returns the empty string if the wrapped function returns NULL, which was a bit surprising to me.What is the rationale for returning the empty string instead of JS
null
in this case?Thanks!
The text was updated successfully, but these errors were encountered: