[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] How to optimize compiling sizeof const?
From: |
Ramsay Jones |
Subject: |
Re: [Tinycc-devel] How to optimize compiling sizeof const? |
Date: |
Thu, 31 Jul 2014 10:41:48 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
On 31/07/14 07:51, Jared Maddox wrote:
>> Date: Tue, 29 Jul 2014 19:11:24 +0800
>> From: "YX Hao" <address@hidden>
>> To: <address@hidden>
>> Subject: [Tinycc-devel] How to optimize compiling sizeof const?
>> Message-ID: <address@hidden>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hi there,
>>
>> We know that tcc generates bigger binary file than gcc for non-small
>> projects. But I'm not meaning the optimization options.
>>
>> Here I find the titled issue when I compile an html5 library (Google's
>> "gumbo"). In the compiled object file and linked binary file, that of tcc
>> you can find the string to be calculated size of is stored, and you will see
>> it will not be used with a debugger, while gcc generates clean file with
>> smaller size. The attached file is a piece of code for testing.
>>
>
> Just to be certain that I'm understanding correctly, you're talking
> about something like this:
>
> size_t size_size()
> {
> return( sizeof( "sizeof" ) );
> }
> void arg_size( void (*func)( const char* ) )
> {
> if( func )
> {
> ( *func )( "sizeof" );
> }
> }
>
> And the behavior in question is that TWO copies of "sizeof" are
> included in the resulting object file, correct? This is specifically a
I thought the OP was complaining that the expression:
sizeof("a string literal")
was causing an _unused_ copy of the string literal to be stored in
the data section. This expression is a compile-time constant and,
once it has been evaluated, the string literal is no longer required
(even at compile time).
However, I may have misunderstood. :-D
ATB,
Ramsay Jones