Results 1 to 2 of 2
Hi Gurus,
I have a quick question. I am supposed to implement a Debug trace when my project is compiled with gcc -DDEBUG option.
I declared a macro as such:
...
- 10-27-2007 #1Just Joined!
- Join Date
- Jun 2007
- Posts
- 34
gcc -DDEBUG option
Hi Gurus,
I have a quick question. I am supposed to implement a Debug trace when my project is compiled with gcc -DDEBUG option.
I declared a macro as such:
#ifdef _DEBUG
#define DEBUG_TRACE(x) printf("%s\n", (x))
#else
#define DEBUG_TRACE(x)
#endif
Then in my code, I am using the DEBUG_TRACE macro. However, I am not outputiing my debug statements wven after compiling with the gcc -DDEBUG option. Can someone please point me what am I doing wrong?
PS: I tried different options like just DEBUG etc. with no avail.
-Thanks in advance
rabantu
- 10-27-2007 #2
You have two choices.
First, you can compile with this:
But a better choice is to do this:Code:gcc -D_DEBUG
The reason is that in C you should avoid using identifiers that begin with an underscore, to avoid collision with identifiers used by those who implement the compiler.Code:#ifdef DEBUG /* not _DEBUG */
Hope this helps.


Reply With Quote