Cancel
Showing results for 
Search instead for 
Did you mean: 

Debug-mode compilation -- what is permitted?

Valued Contributor
Valued Contributor

I have learned that C++ NXOpen code must be built against the "Multi-threaded DLL (/MD)" version of the MS C Runtime Library. I understand that the reason is that NX 9 is built against this library, and that user code must use this same library to ensure binary compatibility and safe passing of STL objects such as std::string and std::vector back and forth between NX 9 and user code.

 

My question is: Is there any safe and simple way to have a "debug"-mode when writing C++ NXOpen code?  Should I even bother having a "Debug" build configuration in my projects?  If I do, must I undefine _DEBUG, and define NDEBUG?

 

I understand that I might get away to some degree with some complicated scheme like enclosing strictly-internal code blocks in


#define _DEBUG
#undef NDEBUG

 

...

 

#undefine _DEBUG

#define _DEBUG

 

And I'm guessing the above might work for compiled-in (inline, non-imported) types in the Standard Library, but that this won't work for linked-in (imported) types, since a project can only link against one Runtime Library.

 

Anyone have any guidance on this general or specific issue?

1 REPLY

Re: Debug-mode compilation -- what is permitted?

Valued Contributor
Valued Contributor

I just called GTAC, and they told me:

 

1) Use the NX 9 New Project wizard to create new projects from scratch instead of upgrading old ones in Visual Studio, because that's the only way to ensure all the arcane required settings are set as necessary.

 

2) Confirmed: do not define _DEBUG in the preprocessor:

"As we discussed you have to use the non-debug C runtime libraries with NX for memory layout compatability. Microsoft's headers use _DEBUG to control what they do in places making it impossible use _DEBUG and the non-debug C runtimes at the same time.

"You can use your own preprocessor #define to indicate debug mode to your code, e.g. "DEBUG" but you cannot use "_DEBUG"."