2

In userspace code, the macro __WORDSIZE is used, included in <bits/wordsize.h>. However, when I do Linux kernel programming, the __WORDSIZE seems not available.

If <bits/wordsize.h> is included, it will receive a compile error, saying:

error: bits/wordsize.h: No such file or directory

but if <bits/wordsize.h> is not included, it will receive another compile error, saying:

error: ‘__WORDSIZE’ undeclared.

It seems that kernel programming doesn't support the <bits/wordsize.h> header file. What should I do to determine the wordsize in Linux kernel programming?

P.S. my compiler version is gcc (GCC) 4.4.6.

closed as off-topic by Shadur, Ramesh, Anthon, jasonwryan, Networker Nov 13 '14 at 20:14

  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • As this is very specifically about programming, i voted to move to SO. However, out of interest, why such an old version of gcc? – HalosGhost Nov 13 '14 at 14:18
  • The gcc's version depends on my company's willing. – Victor Nov 13 '14 at 14:20
  • That's deeply unfortunate. It's now 5 minor releases behind… – HalosGhost Nov 13 '14 at 14:22
  • @HalosGhost I am also very annoyed about it, because many new features are not available. – Victor Nov 13 '14 at 14:32
  • 2
    The asm/types.h should have BITS_PER_LONG set, which should be the word size to Robert Love's Linux Kernel Development (sixth result in the search). – muru Nov 13 '14 at 14:42