LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-20-2004, 02:35 PM   #1
shy
Member
 
Registered: Dec 2002
Location: Russia
Distribution: ASP linux
Posts: 94

Rep: Reputation: 15
gcc macroses for automating debugging


I want to make a debugging subsystem like in the following example:
Code:
#include <stdio.h>

/*
   to be put in some general debug.h in the way:
   #define MAIN_DEBUG
   #define SOME_OTHER_FUNCTION_NAME_DEBUG
 */

#define REAL_DEBUG(msg)                         \
do {                                            \
        printf ("debug message " msg "\n");     \
} while(0)

int main (void)
{
/*Here I want to check if macros "__FUNCTION__" + "_DEBUG" defined.*/
#ifdef MAIN_DEBUG
        #define DEBUG(x) REAL_DEBUG(x)
#else
        #define DEBUG(X)
#endif
        DEBUG("test");
}
The thing is that I want to be able to disable all debugging output in one function by just commenting out one line in some header file.

The questions are:
1. Can I somehow write just one line in the beginning of each function expanding to
Code:
#ifdef MAIN_DEBUG
        #define DEBUG(x) REAL_DEBUG(x)
#else
        #define DEBUG(X)
#endif
?
2. Can it be automated so I don't have to write the function name explicitly, i.e. not
Code:
#ifdef MAIN_DEBUG
but something like
Code:
#ifdef __FUNCTION__ + "_DEBUG"
?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating Swaret nny0000 Slackware 2 10-13-2005 06:14 PM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM
automating dialup rlucas Linux - Networking 1 08-07-2004 08:06 PM
Automating things... DarkSTech Linux - Networking 1 03-06-2003 11:31 AM
Automating the install Tijoux Linux - Software 2 01-20-2002 10:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration