Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does GNU configure define macros for SIZEOF_INT etc. as specific integer values?

Tags:

c

If you're going to define these at all, why not define them as

#define SIZEOF_INT sizeof(int)

etc. so they are correct even if someone tries to use them to compile against a different architecture?

like image 888
ijt Avatar asked May 17 '17 21:05

ijt


1 Answers

I found the answer a minute after asking the question. These macros are sometimes used in the predicates of #if etc. where sizeof calls cannot be evaluated.

For example

#if SIZEOF_LONG_LONG_INT == 8
stuff
#endif
like image 122
ijt Avatar answered Nov 15 '22 04:11

ijt