4

I am wondering if there is a way to simply output to the terminal the value of some global/standard definitions of C/GCC, e.g. using the echo command, without writing C code and using printf?

I mean things like __GNUC_, __UINT64_MAX__, _POSIX_C_SOURCE ...

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Dumbo
  • 1,516
  • 6
  • 16
  • 20

2 Answers2

10

You can view the value of any defined constant as follows:

echo __GNUC__ | gcc -E -

If you need to add an include file:

echo O_APPEND | gcc -include fcntl.h -E -
Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
2
gcc -E file.c

Will do what you want it to. It's a good idea to browse it's manual, as assembly output is possible as well, not to mention lots of other features.

TNW
  • 2,080
  • 16
  • 14