Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse marks macros from inttypes.h as syntax errors
Eclipse marks macros from inttypes.h as syntax errors [message #1016685] Thu, 07 March 2013 10:56 Go to next message
Konstantin Miller is currently offline Konstantin Miller
Messages: 3
Registered: March 2013
Junior Member
Hi!

When I am using macros from inttypes.h (that allow for portable usage of printf-like formatting string across architectures), e.g., like this:

printf("This is a 64-bit integer: %"PRId64".\n", (int64_t)23);


Eclipse marks the line as "Syntax error". This is very annoying in code that uses many printf-like functions (fprintf, sprintf, fscanf, sscanf, etc). I am compiling the code using a manually generated makefile and everything compiles and runs so that I assume that the problem is with Eclipse?

Best,
Konstantin
Re: Eclipse marks macros from inttypes.h as syntax errors [message #1016917 is a reply to message #1016685] Fri, 08 March 2013 08:27 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1949
Registered: July 2009
Senior Member
Havae a look at the code from inttypes.h
/* The ISO C99 standard specifies that these macros must only be
   defined if explicitly requested.  */
#if !defined __cplusplus || defined __STDC_FORMAT_MACROS


=> you must define __STDC_FORMAT_MACROS to get it working.

I guess you are setting this define in your Makefile. You should add this define in Eclipse to Project Properties->C/C++ General->Paths and Symbols


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Eclipse marks macros from inttypes.h as syntax errors [message #1017002 is a reply to message #1016917] Fri, 08 March 2013 14:36 Go to previous messageGo to next message
Konstantin Miller is currently offline Konstantin Miller
Messages: 3
Registered: March 2013
Junior Member
Hi Axel,

thanks for your answer. I didn't mention that in my question but I am already defining __STDC_FORMAT_MACROS prior to including inttypes.h. So, this seems not to be the issue.

Do you also observe the problem with the PRIxx and SCNxx macros?

Best,
Konstantin
Re: Eclipse marks macros from inttypes.h as syntax errors [message #1018221 is a reply to message #1017002] Wed, 13 March 2013 12:33 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1949
Registered: July 2009
Senior Member
Konstantin Miller wrote on Fri, 08 March 2013 15:36
I didn't mention that in my question but I am already defining __STDC_FORMAT_MACROS prior to including inttypes.h.

Where do you define it?
Do you use something like this?
#define__STDC_FORMAT_MACROS
#include <inttypes.h>

This did not work for me. You have to set the define in Project Properties->C/C++ General->Paths and Symbols


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Eclipse marks macros from inttypes.h as syntax errors [message #1068168 is a reply to message #1018221] Fri, 12 July 2013 13:56 Go to previous message
Konstantin Miller is currently offline Konstantin Miller
Messages: 3
Registered: March 2013
Junior Member
Thanks! This works!

Best,
Konstantin
Previous Topic:Max heap 512m
Next Topic:Problems when programmatically adding macros
Goto Forum:
  


Current Time: Tue Sep 16 07:26:01 GMT 2014

Powered by FUDForum. Page generated in 0.02635 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software