4 ms·
Could it not have been expressed with just a macro? EDIT: Down votes? lol
by acron0 12y ago
Could it not have been expressed with just a macro?
EDIT: Down votes? lol
- matt42 12y agoHere is the tranformation done by the preprocessor: https://gist.github.com/matt-42/a53cc0b0a8d8f1cf673f https://gist.github.com/matt-42/a53cc0b0a8d8f1cf673f It would be really convenient to have it done by the C preprocessor, but it seems impossible to me to get it with macro only. Am I wrong?
- bratsche 12y agoIt seems like you could do something like: #define IOD_SYM(name) iod_define_symbol(name, _##name); #define S(name) s::_##name; Then use S(test) instead of @test and any files that need these symbols defined could just have IOD_SYM(test) at the top or something.
- matt42 12y ago#define S(name) is a bit dangerous. It would affect any C/C++ function called S.
- pfultz2 12y agoActually using [ZLang](https://github.com/pfultz2/ZLang https://github.com/pfultz2/ZLang), you could define them like this: #define IOD_DEFINE_SYMBOL(name) iod_define_symbol(name, _##name) #define IOD_S(name) s::_##name #define ZLANG_iod_define (IOD_DEFINE_SYMBOL) #define ZLANG_iod_s (IOD_S) And then compiling with `-DZLANG_NS=iod` you can call it like this: // Define symbols $(define hello) $(define message) auto hello_api = make_api( // The hello world procedure. $(s hello) = [] () { return D($(s message) = "Hello world."); } ); Also, ZLang can be supported without a need for a dependency on ZLang.