public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* unsigned long long int ????
@ 2002-08-20 23:23 Suni B. Bongale
  2002-08-21  1:25 ` Claudio Bley
  0 siblings, 1 reply; 4+ messages in thread
From: Suni B. Bongale @ 2002-08-20 23:23 UTC (permalink / raw)
  To: gcc-help

The version number of the gcc that I am using is  gcc version 2.95.4
 
I have written a macro in the follwing source code to retrieve a
unsigned long long value form a character array
But when I compiled the code its giving error.
 
 
#include <stdio.h>
 
typedef unsigned long long U64bit;
 
#define   GTP_GET_U64BIT(p_buff)   (unsigned long long)\
          ((U64bit)((*(p_buff)) << 56) | (U64bit)((*(p_buff + 1)) << 48)
| \
          ((U64bit)((*(p_buff +2)) << 40) | (U64bit)((*(p_buff + 3)) <<
32) | \
          ((U64bit)((*(p_buff +4)) << 24) | (U64bit)((*(p_buff + 5)) <<
16) | \
          (U64bit)((*(p_buff + 6)) << 8) | (U64bit)(*(p_buff + 7)))
main()
{
    unsigned char imsi[9] = {255,255,255,255,255,255,255,255,255};
    unsigned long long b;
 
    b = GTP_GET_U64BIT(&imsi[0]);
    printf("%ul",b);
}
 
test1.c: In function `main':
test1.c:15: warning: left shift count >= width of type
test1.c:15: warning: left shift count >= width of type
test1.c:15: warning: left shift count >= width of type
test1.c:15: warning: left shift count >= width of type
test1.c:15: parse error before `;
 
Thanks for any help!
 
Regards
Sunil Bongale
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: unsigned long long int ????
  2002-08-20 23:23 unsigned long long int ???? Suni B. Bongale
@ 2002-08-21  1:25 ` Claudio Bley
  0 siblings, 0 replies; 4+ messages in thread
From: Claudio Bley @ 2002-08-21  1:25 UTC (permalink / raw)
  To: gcc-help

>>>>> "Suni" == Suni B Bongale <sbongale@nulinkinc.com> writes:

    Suni> The version number of the gcc that I am using is gcc version
    Suni> 2.95.4 I have written a macro in the follwing source code to
    Suni> retrieve a unsigned long long value form a character array
    Suni> But when I compiled the code its giving error.
 
It's giving errors because of unbalanced parenthesis. You have more
opening parenthesis than closing ones in your macro definition.

You should really use an editor which shows you the extent of your
parens (Emacs is good ;-).
 
I suppose what you wanted was something like:

#define   GTP_GET_U64BIT(p_buff)   (unsigned long long) \
          (((U64bit)(*(p_buff))       << 56) | \
           ((U64bit)((*(p_buff + 1))) << 48) | \
           ((U64bit)((*(p_buff + 2))) << 40) | \
           ((U64bit)((*(p_buff + 3))) << 32) | \
           ((U64bit)((*(p_buff + 4))) << 24) | \
           ((U64bit)((*(p_buff + 5))) << 16) | \
           ((U64bit)((*(p_buff + 6))) <<  8) | \
           ((U64bit)((*(p_buff + 7)))))

-- 
Claudio Bley                                                        _ 
                                             ASCII ribbon campaign ( )
ICQ# 83197241                                 - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: unsigned long long int ????
@ 2000-10-12 14:39 Nick DiToro
  0 siblings, 0 replies; 4+ messages in thread
From: Nick DiToro @ 2000-10-12 14:39 UTC (permalink / raw)
  To: 'Liguo Song', gcc-help

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]

Title: RE: unsigned long long int ????





Try %lX (percent ELL X) instead of %X 
int main()
{
    unsigned long long int l = 0xFFFFFFFF00000000;


    printf("%lX\n", l);
}



-----Original Message-----
From: Liguo Song [ mailto:liguo.song@vanderbilt.edu ]
Sent: Thursday, October 12, 2000 11:42 AM
To: gcc-help@gcc.gnu.org
Subject: unsigned long long int ????


In the manual of GCC, it stated that long long int (64 bits) is
supported. But, I failed to make use of it in my program.


The following program would compile fine, but gives me the wrong output.
(0FFFFFFFF and 1FFFFFFFF).


The version number of the gcc that I am using is egcs-2.91.66.


Two questions:
    1. How to successfully printf the long long int?
    2. What else I need to do to make it work?


Thanks for any help!



Liguo (Leo)



**********************************************
int main()
{
    unsigned long long int l = 0xFFFFFFFF00000000;


    printf("%X%X\n", l);
    printf("%X%X\n", l+1ULL);
}




^ permalink raw reply	[flat|nested] 4+ messages in thread

* unsigned long long int ????
@ 2000-10-12  8:43 Liguo Song
  0 siblings, 0 replies; 4+ messages in thread
From: Liguo Song @ 2000-10-12  8:43 UTC (permalink / raw)
  To: gcc-help

In the manual of GCC, it stated that long long int (64 bits) is
supported. But, I failed to make use of it in my program.

The following program would compile fine, but gives me the wrong output.
(0FFFFFFFF and 1FFFFFFFF).

The version number of the gcc that I am using is egcs-2.91.66.

Two questions:
    1. How to successfully printf the long long int?
    2. What else I need to do to make it work?

Thanks for any help!


Liguo (Leo)


**********************************************
int main()
{
    unsigned long long int l = 0xFFFFFFFF00000000;

    printf("%X%X\n", l);
    printf("%X%X\n", l+1ULL);
}



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-08-21  8:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-20 23:23 unsigned long long int ???? Suni B. Bongale
2002-08-21  1:25 ` Claudio Bley
  -- strict thread matches above, loose matches on Subject: below --
2000-10-12 14:39 Nick DiToro
2000-10-12  8:43 Liguo Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).