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]

 



Thanks for your help.


Internal Use Only

-----Original Message-----
From: Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
Sent: Wednesday, July 29, 2020 4:19 PM
To: Kannuswamy, Nanthakumar <nanthakumar.kannuswamy@xxxxxxxxxx>
Cc: gcc-help@xxxxxxxxxxx; Ramakrishnan, Murugan <murugan.ramakrishnan@xxxxxxxxxx>
Subject: Re: Need suggestion for using intypes.h features in centos5 gcc 4.1.2 compiler version.

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.


This communication is the property of E*TRADE Financial Corporation and its affiliates and does not constitute an offer to sell or the solicitation of an offer to buy any security. It is intended only for the person to whom it is addressed and may contain information that is privileged, confidential, or otherwise protected from disclosure. Distribution or copying of this communication, or the information contained herein, by anyone other than the intended recipient is prohibited. If you have received this communication in error, please immediately notify E*TRADE Financial Corporation at (800) 387-2331, and delete and destroy any copies hereof.





[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