This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Defining and undefining #defines from command line
- From: José Luis García Pallero <jgpallero at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 20 Nov 2009 13:24:30 +0100
- Subject: Defining and undefining #defines from command line
Hi,
I'm the simple program:
#include<stdio.h>
#define AGE 29
int main(){
??? printf("Hello, I'm %d years old\n",AGE);
??? return 0;
}
I compile it: gcc hello.c -o hello and the result is: Hello, I'm 29 years old.
But if I try to define from gcc instantiation other AGE value as: gcc
-UAGE -DAGE=30 hello.c -o hello. In this case appears the warning:
hello.c:2:1: warning: "AGE" redefined
<command-line>: warning: this is the location of the previous definition
If I use gcc -DAGE=30 -UAGE hello.c -o hello no warnings appears, but
the result is: Hello, I'm 29 years old.
In gcc manual says: "-D and -U options are processed in the order they
are given on the command line"
Anybody knows the correct way for change any defined constant or macro
in the code. I'm using gcc 4.3.4 in Debian
Thanks
--
*****************************************
José Luis García Pallero
jgpallero@gmail.com
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************