468,512 Members | 1,382 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

warning: use of C99 long long integer constant

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
Apr 1 '08 #1
21 7762
On Apr 1, 8:39 am, Sebastian Faust <sebastian.fa...@googlemail.com>
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}

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
Apr 1 '08 #2
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.

Philip
Apr 1 '08 #3
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
Apr 1 '08 #4
Hi,

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

Regards,
Sebastian

On 1 Apr., 15:03, Philip Potter <p...@doc.ic.ac.ukwrote:
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.

Philip
Apr 1 '08 #5
Hey guys,

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

Cheers,
Sebastian

On 1 Apr., 14:39, Sebastian Faust <sebastian.fa...@googlemail.com>
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}

Regards and thanks a lot,
Sebastian


Apr 1 '08 #6
[Top-posting corrected]
Sebastian Faust <se*************@googlemail.comwrites:
On 1 Apr., 15:03, Philip Potter <p...@doc.ic.ac.ukwrote:
>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.
<snip>
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?

--
Ben.
Apr 1 '08 #7
On 1 Apr., 16:16, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
[Top-posting corrected]

Sebastian Faust <sebastian.fa...@googlemail.comwrites:
On 1 Apr., 15:03, Philip Potter <p...@doc.ic.ac.ukwrote:
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.
<snip>
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?

--
Ben.
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
Apr 1 '08 #8
Sebastian Faust <se*************@googlemail.comwrites:
On 1 Apr., 16:16, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
>Sebastian Faust <sebastian.fa...@googlemail.comwrites:
On 1 Apr., 15:03, Philip Potter <p...@doc.ic.ac.ukwrote:
Sebastian Faust wrote:
<snip>
Unfortunately, I don't find lots of information on this
warning.
<snip>
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}
<snip>
>Did you read my message? Was that not the problem?

--
Ben.
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.

--
Ben.
Apr 1 '08 #9
On 1 Apr., 16:30, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
Sebastian Faust <sebastian.fa...@googlemail.comwrites:
On 1 Apr., 16:16, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
Sebastian Faust <sebastian.fa...@googlemail.comwrites:
On 1 Apr., 15:03, Philip Potter <p...@doc.ic.ac.ukwrote:
Sebastian Faust wrote:
<snip>
Unfortunately, I don't find lots of information on this
warning.
<snip>
The following code produces the warning:
const static unsigned long long data[1] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL}
<snip>
Did you read my message? Was that not the problem?
--
Ben.

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
Apr 1 '08 #10
Sebastian Faust <se*************@googlemail.comwrites:
<snip lots but the code is:>

const static unsigned long long data[] = {
0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL
};
On 1 Apr., 16:30, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
>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.
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.

--
Ben.
Apr 1 '08 #11
Martin Ambuhl said:

<snip>
The largest
integer you can use in C90 (or C89) is ULONG_MAX which is only
guaranteed to be at least 14294967295
s/1//

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Apr 1 '08 #12
On 1 Apr., 16:46, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
Sebastian Faust <sebastian.fa...@googlemail.comwrites:

<snip lots but the code is:>

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

};
On 1 Apr., 16:30, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
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.

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?
Apr 1 '08 #13
Sebastian Faust wrote:
On 1 Apr., 16:46, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
>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?
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
Apr 1 '08 #14
"Sebastian Faust" <se*************@googlemail.comwrote in message
news:65**********************************@s19g2000 prg.googlegroups.com...
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

--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking

Apr 1 '08 #15
On 1 Apr., 17:43, Philip Potter <p...@doc.ic.ac.ukwrote:
Sebastian Faust wrote:
On 1 Apr., 16:46, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
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?

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...
Apr 1 '08 #16
Sebastian Faust <se*************@googlemail.comwrites:
On 1 Apr., 17:43, Philip Potter <p...@doc.ic.ac.ukwrote:
>Sebastian Faust wrote:
On 1 Apr., 16:46, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
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?

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...
<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.

--
Ben.
Apr 1 '08 #17
Hi Ben,

On 1 Apr., 20:05, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
Sebastian Faust <sebastian.fa...@googlemail.comwrites:
On 1 Apr., 17:43, Philip Potter <p...@doc.ic.ac.ukwrote:
<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.
Apr 1 '08 #18
Sebastian Faust wrote:
On 1 Apr., 17:43, Philip Potter <p...@doc.ic.ac.ukwrote:
>Sebastian Faust wrote:
>>On 1 Apr., 16:46, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
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?
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...
You have two "proper" solutions:

1) Change the distributed development environment. It's broken if you
expect it to be able to handle long long.
2) Change your code to be C90 (ie no "long long"). If you need an
integer bigger than 2**32-1, implement your own bignum library.

I don't know how to change the source to avoid your warnings but still
use long long. Even if there were, it would be a hacky solution. The
whole point of -ansi -pedantic is that it isn't supposed to allow such
things.

Philip
Apr 1 '08 #19
Philip Potter wrote:
Martin Ambuhl wrote:
>... 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.
Nit: With the minor corrections:
"The largest integer you can use in C90 (or C89) is ULONG_MAX, which is
only guaranteed to be at least 4294967295, the largest value representable
in 32 bits."

Martin's statement appears to be correct.

--
Thad
Apr 2 '08 #20
Sebastian Faust <se*************@googlemail.comwrites:
On 1 Apr., 17:43, Philip Potter <p...@doc.ic.ac.ukwrote:
>Sebastian Faust wrote:
On 1 Apr., 16:46, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
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?

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...
The settings you're currently using are wrong for the code you're
compiling. If you don't have a mechanism for correcting such errors,
you've got a serious problem.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 2 '08 #21
Thad Smith wrote:
Philip Potter wrote:
>Martin Ambuhl wrote:
>>... 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.

Nit: With the minor corrections:
"The largest integer you can use in C90 (or C89) is ULONG_MAX, which is
only guaranteed to be at least 4294967295, the largest value representable
in 32 bits."

Martin's statement appears to be correct.
Whoops! I read his article as "the largest integer you can use is
14294967295" and completely missed the intermediate words in the sentence.
Apr 2 '08 #22

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jeff Gilchrist | last post: by
6 posts views Thread by fctk | last post: by
17 posts views Thread by jithoosin | last post: by
10 posts views Thread by krunalb | last post: by
3 posts views Thread by wolverine | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.