Role of __WORDSIZE in compilation

10.3k Views Asked by At

Below are the contents of /usr/include/x86_64-linux-gnu/gnu/stubs-32.h file:

#include <bits/wordsize.h>    
#if __WORDSIZE == 32
# include <gnu/stubs-32.h>
#elif __WORDSIZE == 64
# include <gnu/stubs-64.h>
#else
# error "unexpected value for __WORDSIZE macro"
#endif

I am on 64 Bit machine, so the result of

#include<stdio.h>
main()
{
printf("Word size : %d\n",__WORDSIZE);
}

is

Word size : 64

So here is the question, what is the role of the system variable __WORDSIZE? I am developing a 32 bit application( using mingw 32 bit compiler) and since my __WORDSIZE is 64 bit, the file /usr/include/x86_64-linux-gnu/gnu/stubs-32.h ultimately results in including /usr/include/x86_64-linux-gnu/gnu/stubs-64.h. I am confused about this part. What are the consequences of this action? Is this normal and if not how can I forcibly include /usr/include/x86_64-linux-gnu/gnu/stubs-32.h?

Thank You in advance.

1

There are 1 best solutions below

3
On BEST ANSWER

It is a manifest constant, intended for internal use by the compiler implementation exclusively; that its name is prefixed by two underscores is a clear indicator that it is not intended for use in user space.