Question

I'm quickly implementing this code http://msdn.microsoft.com/en-us/library/hskdteyh(v=vs.80).aspx into my program, since I needed to get some CPU info, however when i get to this part of the code:

__cpuid(CPUInfo, 0x80000000);
    nExIds = CPUInfo[0];

the next for loop begins to roll forever, so I placed a break point and the hit count kept growing, turned out that nExIDs gets set to 2147483656, which would make the execution of the rest of the code hours if not weeks(so it's obviously an error).It doesn't say the feature is deprecated or anything, so it shouldn't be giving me trouble, right?If it's relevant to the *__cpuid* function, I'm running it on Windows 7 Home Premium 64-bit on a VAIO laptop.The CPU I'm querying is an Intel(R) Core(TM) i5 CPU M 460 @ 2.53GHz with 2 cores(4 logical).Maybe I need to pass it a different value other than 0x80000000?But how do I determine how much?

Was it helpful?

Solution

Ok I figured it out, the example in MSDN has a bug - if the feature is not supported it sets it to a negative value, but nExIds is an unsigned int, so when you set it to the negative invalid value, it automatically gets set to 2147483656.So I must use int instead of unsigned int.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top