Link to home
Start Free TrialLog in
Avatar of carlpaddick
carlpaddick

asked on

Preprocessor directive from running within Developer Studio?

I'm creating a little Win32 console app from within Developer Studio.  Whilst I am developing in debug, I am putting

#ifdef _DEBUG
getchar();
#endif

statements in various places, to stop the console window disappearing when the program terminates.

I would like to know if there is a preprocessor directive similar to _DEBUG that stipulates that the program is being executed from Developer Studio, rather than the command line such as _DEVELOPERSTUDIO.  This would eliminate the confusion of having to hit return if the debug version of the program was run on the command line.
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

simply do a runtime check instead, pre-processor directives are resolved at compile time so they will be still there when running in DevStdio or on cmd line

/* global */
int stopper = 0;

then in main set it to 1 if your passed a certain command line option

in the code
if(stopper) getch();

open project settings and add the option
ASKER CERTIFIED SOLUTION
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
anyway really you should compile a release when running out of DevStd, this would completley solve all probs
Avatar of carlpaddick
carlpaddick

ASKER

Thanks for all of your comments makerp.  You've posted some very useful ones.  Please have the points.
cheers, glad to help