[Top][All Lists]

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

Re: [Tinycc-devel] [PATCH] pp-defines

From: Charles Gordon
Subject: Re: [Tinycc-devel] [PATCH] pp-defines
Date: Mon, 5 Jan 2015 05:03:44 +0100

On 4 janv. 2015, at 15:10, Thomas Preud'homme <address@hidden> wrote:
> Le dimanche 4 janvier 2015, 07:53:44 Sergey Korshunoff a écrit :
>>> This patch seems unnecessary as tcc_define_symbol with a third argument
>>> NULL is equivalent as setting it to 1 (#define FOO is the same as #define
>>> FOO 1)
>> I trying  to be exactly the same as gcc.  And this macros in gcc are
>> as "1" not ""
> Do you have an example of where this difference matters? For all purpose 
> #define 
> FOO 1 and #define FOO should be identical.

Your explanation is confusing:

#define FOO


#define FOO 1

are indeed different macro definitions with different expansions.

But we are discussing predefined macros that are defined using the same 
function as for command line macro definitions

-DFOO and -DFOO=1 command line options have identical behavior, namely defining 
macro FOO with value 1

parse_option_D() calls tcc_define_symbol() with the value after ‘=' or NULL if 
none is present.
tcc_define_symbol() checks for NULL and uses “1” as the <default> value.
tcc_define_symbol() creates a string from its arguments and then calls the 
actual parser parse_define().

Thus, If you want to add new predefined macros with the value 1, it is safe to 
pass NULL instead of “1” as a value.
It also produces less code, but is more confusing ;-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]