warning: use of C99 long long integer constant

  • Thread starter Sebastian Faust
  • Start date
S

Sebastian Faust

Hi,

Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?

The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}

Regards and thanks a lot,
Sebastian
 
B

Ben Bacarisse

Sebastian Faust said:
Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?

The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}
; /* <- missing */

Both long long and its associated constants are features of C99. You
are probably not compiling in C99 mode, but instead are asking for the
compiler to check your program against the older C90 standard.

If you are using gcc (as seems probable), add -std=c99 to the command
line.

You will also be warned that you give an array length of 1 but include
to elements in the initialization.
 
J

Julienne Walker

Hi,

Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?

The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}

Regards and thanks a lot,
Sebastian

You neglected to post the warning. However, I'm surprised you don't
get an error since you try to initialize an array of 1 with two
values.


-Jul
 
P

Philip Potter

Sebastian said:
Hi,

Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?

The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}

Aside from the warning (which Ben Bacarisse has explained), note that
you are trying to initialize an array of size 1 with two members.

Please quote the warning in the message as well as the subject.

Philip
 
S

Sebastian Faust

Hi,

Thanks! it works! It was just a copy&paste typo... I copied the
relevant code and then I made this typo...

Thanks again,
Sebastian
 
S

Sebastian Faust

Hi,

Btw. is there a possibility to get rid of this warning with some sort
of typecast?

Regards,
Sebastian

Sebastian said:
Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}

Aside from the warning (which Ben Bacarisse has explained), note that
you are trying to initialize an array of size 1 with two members.

Please quote the warning in the message as well as the subject.

Philip
 
S

Sebastian Faust

Hey guys,

Could you please tell me if there is any way to get rid of this
warning by applying some typecast?

Cheers,
Sebastian
 
B

Ben Bacarisse

[Top-posting corrected]
Sebastian Faust said:
Sebastian said:
Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}

Aside from the warning (which Ben Bacarisse has explained), note that
you are trying to initialize an array of size 1 with two members.

Please quote the warning in the message as well as the subject.
Btw. is there a possibility to get rid of this warning with some sort
of typecast?

Did you read my message? Was that not the problem?
 
S

Sebastian Faust

[Top-posting corrected]



Sebastian Faust said:
Sebastian Faust wrote:
Hi,
Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}
Aside from the warning (which Ben Bacarisse has explained), note that
you are trying to initialize an array of size 1 with two members.
Please quote the warning in the message as well as the subject.
Btw. is there a possibility to get rid of this warning with some sort
of typecast?

Did you read my message? Was that not the problem?

Yes that solved the problem, but I cannot change the option how the
program is compiled. So, is there a way to change the sourcecode?
Although I am not sure if this is actually a good approach...

Cheers,
Sebastian
 
B

Ben Bacarisse

Sebastian Faust said:
Sebastian Faust said:
Sebastian Faust wrote:
Unfortunately, I don't find lots of information on this
warning.
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}
Did you read my message? Was that not the problem?

Best not to quote sigs.
Yes that solved the problem, but I cannot change the option how the
program is compiled. So, is there a way to change the sourcecode?
Although I am not sure if this is actually a good approach...

Ah, then you are in trouble, since you are compiling C99 with a
compiler that is expecting something else.

In such a situation I would not want to turn off the warnings. I'd
want then all and I'd keep checking that none of them was indicating a
more serious problem.
 
S

Sebastian Faust

Sebastian Faust said:
Sebastian Faust wrote:
Unfortunately, I don't find lots of information on this
warning.
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}
Did you read my message? Was that not the problem?

Best not to quote sigs.
Yes that solved the problem, but I cannot change the option how the
program is compiled. So, is there a way to change the sourcecode?
Although I am not sure if this is actually a good approach...

Ah, then you are in trouble, since you are compiling C99 with a
compiler that is expecting something else.
Ok! Thanks! Is there a way to solve these particular warnings (use of
C99 long long...) with some change in the code? The reason for this is
that there are hundreds of these warnings and I don't wanna frustrate
the guy who has to compile the code.

Cheers,
Sebastian
 
B

Ben Bacarisse

<snip lots but the code is:>

const static unsigned long long data[] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL
};
Ok! Thanks! Is there a way to solve these particular warnings (use of
C99 long long...) with some change in the code? The reason for this is
that there are hundreds of these warnings and I don't wanna frustrate
the guy who has to compile the code.

Not that I know of. Try posting in a gcc group. The real problem is
not the warning or the code but the fact that, for some reason, you
are not allowed to tell the compiler what language it is seeing! That
is not a sane restriction to put on a build system.

The next release of your compiler may choose not to accept long long
and its constants, and your code will just stop working. Your code
compiles at the moment due to the good graces of your compiler -- as
an extension it is allowing long long in C90 mode. This is not a safe
way to proceed.
 
M

Martin Ambuhl

Sebastian said:
Hi,

Unfortunately, I don't find lots of information on this warning. It
occurs if I compile with -pedantic but I am not sure how I can resolve
this problem. Do you have an idea?

The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}

The gcc-specific information below is actually off-topic here, but the
distinction between which standards support what and the need your
documentation to check for what your compiler supports and how to call
it remains topical:

The standards before C99, the ones used for the gcc compile flags -ansi
or -std=c89 or -std=iso9899:1990 or -std=iso9899:199409, did not provide
the integer types [signed|unsigned] long long [int]. The largest
integer you can use in C90 (or C89) is ULONG_MAX which is only
guaranteed to be at least 14294967295, equivalent to 32 bits. Your
values require a 63 bit value at least (note that you don't touch the
sign bit). If you insist on using those values, invoke gcc with the
(equivalent) -std=c99 or -std=c9x or -std=9899:1999 or -std=9899:199x flags.
 
P

Philip Potter

Martin said:
Sebastian said:
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}

The standards before C99, the ones used for the gcc compile flags -ansi
or -std=c89 or -std=iso9899:1990 or -std=iso9899:199409, did not provide
the integer types [signed|unsigned] long long [int]. The largest
integer you can use in C90 (or C89) is ULONG_MAX which is only
guaranteed to be at least 14294967295, equivalent to 32 bits.

That's the largest integer you can /portably/ use in C90.
Your
values require a 63 bit value at least (note that you don't touch the
sign bit).

There is no sign bit; he's dealing with unsigned types only.
 
S

Sebastian Faust

<snip lots but the code is:>

const static unsigned long long data[] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL

};
Ok! Thanks! Is there a way to solve these particular warnings (use of
C99 long long...) with some change in the code? The reason for this is
that there are hundreds of these warnings and I don't wanna frustrate
the guy who has to compile the code.

Not that I know of. Try posting in a gcc group. The real problem is
not the warning or the code but the fact that, for some reason, you
are not allowed to tell the compiler what language it is seeing! That
is not a sane restriction to put on a build system.

The next release of your compiler may choose not to accept long long
and its constants, and your code will just stop working. Your code
compiles at the moment due to the good graces of your compiler -- as
an extension it is allowing long long in C90 mode. This is not a safe
way to proceed.
I know that in VC++ although it followed only the C90 standard there
was a way for 64 bit integers with __int64. Is there something like
this for gcc?
 
P

Philip Potter

Sebastian said:
I know that in VC++ although it followed only the C90 standard there
was a way for 64 bit integers with __int64. Is there something like
this for gcc?

This answer may seem unhelpful but the datatype you describe is called
"long long". long long was in gcc before C99 standardized it.

*Why* can't you change the options on your compiler? *Why* do you need a
guaranteed 64-bit integer type?

Philip
 
S

Stephen Sprunk

Sebastian Faust said:
Could you please tell me if there is any way to get rid of this
warning by applying some typecast?

Typecasting is something done to actors. In C, you "cast" things.

And no, you can't get rid of the warning with a cast because the problem is
that you're trying to compile a C99 program with a C90 compiler. The
solution is to upgrade or properly invoke your compiler in C99 mode.

A cast is almost always the wrong solution to a problem.

S
 
S

Sebastian Faust

This answer may seem unhelpful but the datatype you describe is called
"long long". long long was in gcc before C99 standardized it.

*Why* can't you change the options on your compiler? *Why* do you need a
guaranteed 64-bit integer type?
It is a distributed development environment, and I don't wanna make
everyone to change his settings...
 
B

Ben Bacarisse

Sebastian Faust said:
It is a distributed development environment, and I don't wanna make
everyone to change his settings...

<off topic now...>

-Wno-long-long

Seems to work with -pedantic and -std=c89, but I emphasize that this
is probably not the right solution.
 
S

Sebastian Faust

Hi Ben,

<off topic now...>

-Wno-long-long

Seems to work with -pedantic and -std=c89, but I emphasize that this
is probably not the right solution.
Thanks a lot for your answer! But again for this I have to change the
compiler flags what I did not want to do.
 

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
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top