Defining and undefining #defines from command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx
(o<
/ / \
V_/_
Use Debian GNU/Linux and enjoy!
*****************************************


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux