misc/174549: UINT64_MAX missing in C++ Program
b.f.
bf1783 at googlemail.com
Wed Dec 26 21:10:01 UTC 2012
The following reply was made to PR misc/174549; it has been noted by GNATS.
From: "b.f." <bf1783 at googlemail.com>
To: bug-followup at freebsd.org, Robin Carey <robin.carey1 at googlemail.com>
Cc:
Subject: Re: misc/174549: UINT64_MAX missing in C++ Program
Date: Wed, 26 Dec 2012 21:02:35 +0000
On 12/26/12, Robin Carey <robin.carey1 at googlemail.com> wrote:
> Dear bf,
>
> I tried defining
>
> # define __STDC_LIMIT_MACROS
>
> before the <stdint.h> inclusion (as you suggested), and it made no
> difference - the error still occurs.
>
>
> If you look at what gets included by <stdint.h>, you will see that that
> definition is made in
>
> <sys/cdefs.h>
>
> anyway .... or that is what it looks like to me .... so it looks likes the
> system makes that definition by
> default (in which case there is no need to define it manually in the source
> code).
Only if you are compiling in C++11 mode (most compilers don't use this
mode except when it is specifically requested, because it is so new,
and is rarely fully supported). The is because the requirement that
some of these standard C definitions be hidden from C++ code except
when __STDC_LIMIT_MACROS and/or __STDC_CONSTANT_MACROS is/are defined
was removed from the C11 standard, and an explicit note was added to
the C++11 standard that the __STDC* macros are not to be considered
when including <cstdint>, so some implementations have taken this as
license to disregard them entirely in C++11 mode:
http://svnweb.FreeBSD.org/base?view=revision&revision=227475
http://svnweb.FreeBSD.org/base?view=revision&revision=227478
I don't have a live system running FreeBSD 9*, but on -CURRENT a
simple program like:
#include <stdint.h>
#ifdef UINT64_MAX
#error UINT64_MAX is defined
#else
#error UINT64_MAX isn't defined
#endif
int main(void)
{
return (0);
}
behaves as expected:
# c++ -Wall -Wextra -std=c++98 -o t1 test1.cc
test1.cc:6:2: error: UINT64_MAX isn't defined
#error UINT64_MAX isn't defined
^
1 error generated.
ret 1
# c++ -Wall -Wextra -std=c++98 -D__STDC_LIMIT_MACROS -o t1 test1.cc
test1.cc:4:2: error: UINT64_MAX is defined
#error UINT64_MAX is defined
^
1 error generated.
ret 1
# c++ -Wall -Wextra -std=c++11 -o t1 test1.cc
test1.cc:4:2: error: UINT64_MAX is defined
#error UINT64_MAX is defined
^
1 error generated.
ret 1
Also, in 9.1, I see in src/sys/sys/stdint.h (installed as
/usr/include/stdint.h):
35#include <machine/_stdint.h>
and in the machine-dependent headers -- for example, in
src/sys/i386/include/_stdint.h
, which is installed as /usr/include/machine/_stdint.h on i386(on
-CURRENT there is one more remove, because some of the i386 and amd64
headers have been unified):
60#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
...
82#define UINT64_MAX 0xffffffffffffffffULL
So are you sure you haven't overlooked something?
b.
More information about the freebsd-bugs
mailing list