This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: I want to dump something when I compile the program. How should I do ?
- From: Martin Jambor <mjambor at suse dot cz>
- To: 冠人 王 <guanjen375 at yahoo dot com dot tw>, 冠人 王 <guanjen375 at yahoo dot com dot tw>, "gcc\@gcc.gnu.org" <gcc at gcc dot gnu dot org>
- Cc:
- Date: Thu, 17 May 2018 13:50:10 +0200
- Subject: Re: I want to dump something when I compile the program. How should I do ?
- References: <1203265537.2309564.1526537840163.ref@mail.yahoo.com> <1203265537.2309564.1526537840163@mail.yahoo.com>
Hi,
On Thu, May 17 2018, 冠人 王 via gcc wrote:
> My work is to modify the gcc source code so as to customize the warning message, when the programmer writing the program violating some rules.
> When the violation occurs, I want to reveal some message such as "guanjen375 warning: the rule ### is violated" on the window.
> How should I do ? Should I modify some file in the gcc source code so that I can print my own message?
> Besides, I want to realize how GCC code executed, so I want to insert some code into GCC source code to check waht happens when those code
> be executed. I try to use "printf" but failed, the message I print
> reveals when I make(after configure), but not reveals at compile time
For this purpose, use fprintf to write your debug message to stderr.
Martin
> If you do not really understand what do I say, let me show an example:
> $gcc -Wunused test.c
> test.c:5:6: warning: unused variable ‘a’ [-Wunused-variable] int a; ^
> becomes
> $gcc -Wunused test.c
> HI,DAVIDtest.c:5:6: warning: unused variable ‘a’ [-Wunused-variable] int a; ^