LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   910725 - where's _DEBUG? (https://www.linuxquestions.org/questions/linux-newbie-8/910725-wheres-_debug-4175432461/)

hamidi2 10-16-2012 06:22 AM

910725 - where's _DEBUG?
 
in Windows, applications usually are deployed in two versions, debug and release. in case of debug, _DEBUG is defined. in Linux, it's a good idea to have such a variable, eg. for when we want to log some info in some cases. this should happen only in debug mode.
is there such a thing in Linux?
thx

David1357 10-16-2012 07:58 AM

Quote:

Originally Posted by hamidi2 (Post 4807028)
in Windows, applications usually are deployed in two versions, debug and release. in case of debug, _DEBUG is defined.

Bruce Schneier and Neils Ferguson say in Practical Cryptography that you should not have a separate debug and release version of your software and they provide several good reasons for this.
Quote:

Originally Posted by hamidi2 (Post 4807028)
in Linux, it's a good idea to have such a variable

Once again, this is not a good idea.
Quote:

Originally Posted by hamidi2 (Post 4807028)
eg. for when we want to log some info in some cases. this should happen only in debug mode. is there such a thing in Linux?

You could create "debug" and "release" targets in your Makefile and pass "-D _DEBUG" in the debug target. However, the real solution is to have only one target and enable logging using a command line switch or a variable in a configuration file. When your software is deployed in some remote location, and you get a request for support, you can ask your customer to enable debug logging. You won't regret it and your customer will thank you.

hamidi2 10-17-2012 12:25 AM

thanx 4 replying
i didn't know that and i got curious to know what might have been the reasons.
then i thought about that. using a config file or a command line switch is a good idea. it even gives more flexibility to customize the behavior of programs. for example, instead of logging or not logging, user may decide to define a debug level and decide what to be logged. sounds a good idea.
thx


All times are GMT -5. The time now is 01:52 PM.