Re: Qeustion about the optimize option

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

 



On 05/10/2011 07:45 AM, Victor wrote:
> I want to build the linux kernel at O0 optimize level. The first problem
> that I face was something about constant.
> I have study it for a day time, but it haven't sovled.
> There is the problem.
> 
> #include <stdio.h>
> 
> int main()
> {
>         int *map;
>         const size_t size = 128 * sizeof(map[0]);
> 
>         ((void)(sizeof(struct { int:-!!(size > ((1UL) << 12)); })));
> }
> 
> When I compile this program use gcc test.c, it fail with
> test.c: In function âmainâ:
> test.c:8:24: error: bit-field â<anonymous>â width not an integer
> constant
> 
> When I compile this program use gcc test.c -O, it success.
> 
> Because I want to debug the linux kernel, how can compile the test
> program above don't use O1 O2 O3.

I can't think of any way of doing this.  The field width expression
isn't an integer constant expression, as required by the standard.
It should be

#include <stdio.h>

int main()
{
        int *map;
#define size (128 * sizeof(map[0]))

        ((void)(sizeof(struct { int:-!!(size > ((1UL) << 12)); })));
}

Andrew.


[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