Preprocessor definition for debug code
Moderator: PPS-Leaders
Preprocessor definition for debug code
Is there a standard preprocessor definition for debug code? I spotted some #ifndef NDEBUGs and #ifdef _DEBUGs, but I don't know if they are platform independent and which one I should use. I'm writing (actually, I'm done) some sort of stack trace for the xml/lua loader, which isn't really necessary for release builds.
Re: Preprocessor definition for debug code
Two answers on this question:
1) NDEBUG (for release) and _DEBUG (for debug) both work. They are defined as compiler flags for both MSVC and GCC builds. For example, NDEBUG is used in util/OrxAssert.h
2) Don't use it unless you have really good reasons to disable/enable a feature under certain build conditions. Every #if makes the code harder to test because it means that code that runs in one environment may fail in another. If your code doesn't severly compromise the release build I suggest to enable it for both build settings.
1) NDEBUG (for release) and _DEBUG (for debug) both work. They are defined as compiler flags for both MSVC and GCC builds. For example, NDEBUG is used in util/OrxAssert.h
2) Don't use it unless you have really good reasons to disable/enable a feature under certain build conditions. Every #if makes the code harder to test because it means that code that runs in one environment may fail in another. If your code doesn't severly compromise the release build I suggest to enable it for both build settings.
Fabian 'x3n' Landau, Orxonox developer
Re: Preprocessor definition for debug code
I'll leave the defines out, then. It only needs a few megabytes of memory (strongly depends on how big the file is), and is probably lightning fast compared to the lua code anyway.
Re: Preprocessor definition for debug code
people that create mainly content (and no code) for Orxonox may use a release build, so I think it's a good thing to enable this feature for all builds.
Fabian 'x3n' Landau, Orxonox developer
Who is online
Users browsing this forum: No registered users and 1 guest