Re: Need suggestion for using intypes.h features in centos5 gcc 4.1.2 compiler version.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 29 Jul 2020 at 21:56, Kannuswamy, Nanthakumar via Gcc-help
<gcc-help@xxxxxxxxxxx> wrote:
>
> Hello All,
>
> We would like to use PRIxxx macros which is defined in <inttypes.h> (introduced in C99)  in our c++ code base which is running on centos5/gcc 4.1.2.  When we compiling the following program using gcc centos5/4.1.2 its compiled successfully
>
> #include <inttypes.h>
> #include <stdio.h>
>
> Int main() {
> Int val = 10;
> printf("Value is %" PRId32, val);
> return 0;
> }
>
> $> gcc PRImacros.c
> Compiled and run successfully.
>
>
> But at the same time, if we compile above program using centos5/g++ 4.1.2 comes as part of bundled gcc 4.1.2 package,  we got the following error
>
> $> g++ PRImacros.cpp
> PRImacros.cpp: In function 'int main()':
> PRImacros.c:8: error: expected `)' before 'PRId32'
>
> Since this PRIxxx is introduced in c99, we tried in the following way too, but got the error
>
> $> g++ -std=c99 PRImacros.cpp
> cc1plus: warning: command line option "-std=c99" is valid for C/ObjC but not for C++
> PRImacros.c: In function 'int main()':
> PRImacros.c:8: error: expected `)' before 'PRId32'
>
> So our question is, Is it possible to use PRIxxx macros in c++ code running on centos5/g++ 4.1.2? If so, how to use it.

It should work if you use g++ -D__STDC_FORMAT_MACROS

The C99 standard said that the macros should not be defined for C++
unless that macro is defined, and the libc headers on CentOS 5 follow
that rule. Later C standards removed that rule, so that the macros
should be unconditionally defined for C++ programs.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux