problem in unsigned long long

V

vadivel.ks

hi,
My code having unsigned long long int64_t;
like that.. compile error message is long followed by long is
illegal,
what is the reason for it?
 
L

Lew Pitcher

hi,
My code having unsigned long long int64_t;
like that.. compile error message is long followed by long is
illegal,
what is the reason for it?

Probably, you are not using a C99-compliant compiler.

Prior to C99, long long was not a standard data type, and instead was
an extension that /some/ compilers provided. Apparently, your compiler
is one that did not implement this non-standard (wrt pre-C99
standards) data type.
 
V

vadivel.ks

Thaks for immediate reply...

how to convert unsigned long long int64_t for gcc
compiler
 
S

Stephen Sprunk

Thaks for immediate reply...

how to convert unsigned long long int64_t for gcc
compiler

GCC has supported "unsigned long long" for many years; if you're not using a
version that understands it, you really need to upgrade.

That makes me wonder, though, what the actual code you're trying to use
looks like. Can you post a compilable example and the error messages you
get?

S
 
D

David Mathog

how to convert unsigned long long int64_t for gcc
compiler

What compiler flags are you using, which version of gcc, which platform?

You may have specified some combination that prevents gcc from
recognizing "long long" as a valid type. Make a tiny example program
and try compiling it with

gcc -std=c99 example example.c

For any fairly recent gcc on most platforms that should handle long long
types correctly.

Regards,

David Mathog
 
M

Martin Ambuhl

Thaks for immediate reply...

how to convert unsigned long long int64_t for gcc
compiler

Current versions of gcc support unsigned long long and current versions
of libraries supplied with gcc have the header <stdint.h> with int64_t
defined there. If you upgrade to a current version of gcc and supplied
libraries, remove the typedef for int64_t from your code and add
#include <stdint.h> to the top of your code.

Otherwise, if you continue to use a (very) old version of gcc without
long long, then you have no type available for int64_t. You can, of
course, lie and
typedef unsigned long int64_t;
but that is not recommended.

It is possible that you are compiling with flags that disable
recognition of long long. 'long long' is not in ISO C90, so compilation
with -std=c89 or its equivalent -ansi _may_ disable recognition of long
long. gcc will, unless told to treat warnings as errors, properly
handle long long but emit warnings. You want to use -std=c99.

If you are compiling without specifying the -std, your copy of gcc will
compile a language very much like C, but not quite. The version of the
nonstandard 'GNU C' language chosen will probably be -std=gnu89, which
will generate diagnostics for long long. For posting to comp.lang.c,
you always want to specify a version of standard C, -ansi or -std=c90
for the old standard, -std=c99 for an attempt at conforming to the new
standard. _Never_ post code for which GNU C is the language used, and
since not specifying a standard is the same as -std=gnu89, that is to be
avoided.
 
R

R Pradeep Chandran

Thaks for immediate reply...

how to convert unsigned long long int64_t for gcc
compiler

Your code is very likely to have something like

typedef unsigned long long int64_t;

Since your question is related to a specific compiler, you have to try
a compiler specific newsgroup. You might want to try gnu.gcc.help GCC
also has mailing lists which might be helpful.

<OT>
GCC version 3.2.2 (around four years old) supports unsigned long long.
It complains only when invoked in c89 mode.
</OT>

Have a nice day,
Pradeep
 
J

J. J. Farrell

My code having unsigned long long int64_t;

Why? What's it supposed to mean? How is int64_t defined? Do you have
like that.. compile error message is long followed by long is
illegal, what is the reason for it?

That depends on the answers to the questions above.
 
K

Keith Thompson

My code having unsigned long long int64_t;
like that.. compile error message is long followed by long is
illegal,

You have what?

If you have a declaration

unsigned long long int64_t;

then you're declaring an object "in64_t" of type "unsigned long long".
That's a bad idea, since "int64_t" is used in C99 as a type name, not
an object name.

Show us the *exact* code you're trying to compile.

If you have <stdint.h>, then you should already have a typedef for
"int64_t", and you don't need to declare it yourself. If your
compiler, in whatever mode you're invoking it in, doesn't support type
"unsigned long long", then you won't be able to use "unsigned long
long" unless you use a different compiler, or the same compiler in a
different mode.

gcc comes with extensive documentation. Try "info gcc".
 
K

Keith Thompson

David Mathog said:
What compiler flags are you using, which version of gcc, which platform?

You may have specified some combination that prevents gcc from
recognizing "long long" as a valid type. Make a tiny example program
and try compiling it with

gcc -std=c99 example example.c

For any fairly recent gcc on most platforms that should handle long long
types correctly.

<OT>

I think you mean either
gcc -std=c99 example.c -o example
or
gcc -std=c99 -c example.c
The latter doesn't attempt to invoke the linker to create an
executable, but it will catch compile-time errors.
</OT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,825
Members
47,371
Latest member
Brkaa

Latest Threads

Top