This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to make a long long


--- Mihnea Balta <dark_lkml at mymail dot ro> wrote:
>     union{
>         struct{
>             unsigned long long a:32;
>             unsigned long long b:32;
>         } gigi;
>         unsigned long long l;
>     } toto;
>     toto.gigi.a = 0xFFFFFFFF;
>     toto.gigi.b = 0xFFFFFFFF;

this might be the best way
but why use unsigned long bit fields and not just
unsigned ints? (or unsigned longs)
e.g. struct{unsigned int a,b;}gigi;

>     unsigned long long l;
>     l = 0xFFFFFFFF;
>     l <<= 32;
>     l += 0xFFFFFFFF;

this involves some calculations.. I doubt that the
compiler can optimize them

>     unsigned long long referenceval;
>     memset(&referenceval, 0xFF,
> sizeof(referenceval));

this works if the bytes are identical.. but usually
they are not

thanks for the reply

Adrian


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]