James King
James King

Reputation: 31

Visual Studio define pre-processor directive in the command line

#ifdef DEBUG_TEST
std::cout << "Hello" << std::endl;
#endif

How can I #define DEBUG_TEST as a command line argument in VS? I have tried /DDEBUG_TESTand the directive does not get defined.

Upvotes: 0

Views: 926

Answers (2)

Keith Nicholas
Keith Nicholas

Reputation: 44288

not sure if its a formatting problem in your question, but this should work :-

 /D "DEBUG_TEST"

or enter it in the preprocessor section

enter image description here

Upvotes: 1

The answer is:

/DDEBUG_TEST

No space, no quotation marks. I believe you can also use gcc syntax with cl, but I'm not sure. If so, this should also work:

-DDEBUG_TEST

Example usage:

cl /DDEBUG_TEST source_code.cpp

Here's the official documentation: https://msdn.microsoft.com/en-us/library/hhzbb5c8.aspx

Upvotes: 0

Related Questions