How portable is __get_cpuid?
Asked Answered
A

1

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?

Arraignment answered 6/12, 2011 at 21:20 Comment(3)
You should include that anyway. Calling a function without a known prototype is illegal in C99.Platto
@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.Interpellant
@Dietrich Epp My bad, I didn't know it was a language extension. That wasn't mentioned in the question.Platto
C
13

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

Chavis answered 6/12, 2011 at 21:26 Comment(1)
Is there a portable C code (Better as Template Library) which allows detecting CPU features? For instant if AVX is supported or not.Parakeet

© 2022 - 2024 — McMap. All rights reserved.