6

I'm using __get_cpuid() to get info on the x86 and x86_64 processors my programs run on. With GCC on Linux and Mac OS, it seems to compile and run OK without include any header, but how portable is that? Would it work with other compilers? Should I include a header for that?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
F'x
  • 12,105
  • 7
  • 71
  • 123
  • 5
    You should include that anyway. Calling a function without a known prototype is illegal in C99. –  Dec 06 '11 at 21:25
  • 2
    @WTP: Being a built-in function, it does not require a prototype. There is no header file to include. The C99 standard does not apply because it is a language extension. – Dietrich Epp Dec 06 '11 at 21:53
  • @Dietrich Epp My bad, I didn't know it was a language extension. That wasn't mentioned in the question. –  Dec 06 '11 at 21:55

1 Answers1

13

It has two leading underscores. Any leading underscore at all is a big hint that the variable or function is not portable.

Zan Lynx
  • 53,022
  • 10
  • 79
  • 131
  • Is there a portable C code (Better as Template Library) which allows detecting CPU features? For instant if AVX is supported or not. – Royi Feb 18 '18 at 13:48