Skip to content
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

documentation for XS in C lacks include file information #1141

Closed
tve opened this issue Jun 6, 2023 · 5 comments
Closed

documentation for XS in C lacks include file information #1141

tve opened this issue Jun 6, 2023 · 5 comments
Labels
fixed - please verify Issue has been fixed. Please verify and close.

Comments

@tve
Copy link
Contributor

tve commented Jun 6, 2023

Describe
There is no information in the XS in C document about include files, i.e. what to #include. In files in the moddable tree I see includes of xs.h, xsmc.h, xsHost.h, mc.xs.h and more. Please provide info on how xs and xsmc interoperate and what to include when & where. I just ran into the issue that xsmc.h seemingly undef's xsDefine, so include xs.h and xsmc.h in that order causes xsDefine to be missing. Maybe including both is a no-no? Help...

@tve
Copy link
Contributor Author

tve commented Jun 6, 2023

Another confusing thing, the example for xsmcGet uses xsVars, why not xsmcVars? This snippet doesn't work unless one includes both xsmc.h and xs.h

xsVars(1);
xsmcGet(xsVar(0), xsGlobal, xsID_foo);
xsmcGet(xsVar(0), xsThis, xsID("foo"));

@phoddie
Copy link
Collaborator

phoddie commented Jun 6, 2023

In short, either include "xsmc.h" or "xs.h" depending on which set of macros you are using.

The example above should use xsmcVars instead of xsVars.

The doc has been updated to adress both of these points. Thank you.

@tve
Copy link
Contributor Author

tve commented Jun 6, 2023

The xsSet documentation mentions xsmcSet and the signatures look identical, but the example only shows xsSet and just s/xsSet/xsmcSet/ doesn't work...

BTW, instead of undefining xsXXX macros in xsmc.h please consider defining them to produce a "do not use" compilation error. As it is, if one uses certain xsXXX macros the compilation succeeds or produces strange errors because the compiler assumes it's an undeclared external function.

@phoddie
Copy link
Collaborator

phoddie commented Jun 6, 2023

BTW, instead of undefining xsXXX macros in xsmc.h please consider defining them to produce a "do not use" compilation error

Nice idea. What's a good way to achieve that using portable C?

@tve
Copy link
Contributor Author

tve commented Jun 6, 2023

Good question...
In GCC, the following works #pragma GCC poison xsVars
In GCC, it also works to do something hacky like #define xsVars(x) Use xsmcVars instead of xsVars when importing xsmc.h
I don't know of a clean std-C solution, but I'm far from an expert at std-C

mkellner pushed a commit that referenced this issue Jun 16, 2023
@phoddie phoddie added the fixed - please verify Issue has been fixed. Please verify and close. label Jun 16, 2023
@phoddie phoddie closed this as completed Jun 27, 2023
mkellner pushed a commit that referenced this issue Jul 12, 2023
mkellner pushed a commit that referenced this issue Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed - please verify Issue has been fixed. Please verify and close.
Projects
None yet
Development

No branches or pull requests

2 participants