I´m using VS2012 C++ Windows 7 and I need to get information about CPU multithreading to calculate the number of available logic processors.
I´m using this code (from This SO Post)
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
uint32_t registers[4];
__asm__ __volatile__ ("cpuid " :
"=a" (registers[0]),
"=b" (registers[1]),
"=c" (registers[2]),
"=d" (registers[3])
: "a" (1), "c" (0));
unsigned CPUFeatureSet = registers[3];
bool hyperthreading = CPUFeatureSet & (1 << 28);
This assembly does not compile, given the following error:
error C2065: '__asm__' : undeclared identifier
I´ve tried changing to __asm __volatile
and putting everything in a single line as:
__asm __volatile ("cpuid " : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]) : "a" (1), "c" (0));
This did not work also, leading to:
error C2400: inline assembler syntax error in 'opcode'; found '('
Help appreciated to solve that.