NE example macroses

Greatings. I have a suggestion that might slightly improve native extension example. I’m pretty sure most people (myself included), when developing ne, copy past example code and then modify it. Example define macroses LIB_NAME, MODULE_NAME. and when you do more than one ne this way, you get compiler warning about redefining macroses. So i suggest to add
#undef LIB_NAME
#undef MODULE_NAME
to end of the example avoid this.

4 Likes

Why not just #ifndef?

Good point. To be absolutely safe you should check whether macros was defined before (it may be defined in some other lib your extension use), and if it was restore it to original value after you no longer need redefined value.
But I think macroses LIB_NAME, MODULE_NAME are not supposed to be used in relation with the ne outside of ne itself, so it is better to undef it.

1 Like

Sure, I can do that.

But I’m not sure how you get a warning, since each translation unit is compiled separately, and these defines are inside that single translation unit?

3 Likes

I’m pretty sure i saw warnings about LIB_NAME, MODULE_NAME being already defined when i debugged some test project with couple ne. To be sure I rebuilded all of my test projects, but could not reproduce these warnings.
It seems like i wasted your time, but I guess its better to be on safe side.

2 Likes