Víte jak rozjet tenhle kód na WIndows XP a v C? Má se includovat WinBase.h ale stejně to hlásí neznámé typy. https://msdn.microsoft.com/en-us/library/windows/desktop/ms683194%28v=vs.85%29.aspx
unknown type SYSTEM_LOGICAL_PROCESSOR_INFORMATION
PCACHE_DESCRIPTOR
error: 'RelationNumaNode' undeclared (first use in this function)
error: invalid type argument of '->' (have 'int')
atak dále a tak dále
// #include <WinDef.h>
#include <windows.h
#include <WinBase.h>
#include <WinNT.h>
#include <malloc.h>
#include <stdio.h>
typedef DWORD *PDWORD;
typedef SYSTEM_LOGICAL_PROCESSOR_INFORMATION *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
typedef BOOL (WINAPI *LPFN_GLPI)(
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION,
PDWORD);
// Helper function to count set bits in the processor mask.
DWORD CountSetBits(ULONG_PTR bitMask)
{
DWORD LSHIFT = sizeof(ULONG_PTR)*8 - 1;
DWORD bitSetCount = 0;
ULONG_PTR bitTest = (ULONG_PTR)1 << LSHIFT;
DWORD i;
for (i = 0; i <= LSHIFT; ++i)
{
bitSetCount += ((bitMask & bitTest)?1:0);
bitTest/=2;
}
return bitSetCount;
}
int test()
{
LPFN_GLPI glpi;
BOOL done = FALSE;
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = NULL;
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION ptr = NULL;
DWORD returnLength = 0;
DWORD logicalProcessorCount = 0;
DWORD numaNodeCount = 0;
DWORD processorCoreCount = 0;
DWORD processorL1CacheCount = 0;
DWORD processorL2CacheCount = 0;
DWORD processorL3CacheCount = 0;
DWORD processorPackageCount = 0;
DWORD byteOffset = 0;
PCACHE_DESCRIPTOR Cache;
glpi = (LPFN_GLPI) GetProcAddress(
GetModuleHandle(TEXT("kernel32")),
"GetLogicalProcessorInformation");
if (NULL == glpi)
{
_tprintf(TEXT("\nGetLogicalProcessorInformation is not supported.\n"));
return (1);
}
while (!done)
{
DWORD rc = glpi(buffer, &returnLength);
if (FALSE == rc)
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
if (buffer)
free(buffer);
buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)
malloc(returnLength);
if (NULL == buffer)
{
printf("\nError: Allocation failure\n");
return (2);
}
}
else
{
printf("\nError %d\n", GetLastError());
return (3);
}
}
else
{
done = TRUE;
}
}
ptr = buffer;
while (byteOffset + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION) <= returnLength)
{
switch (ptr->Relationship)
{
case RelationNumaNode:
// Non-NUMA systems report a single record of this type.
numaNodeCount++;
break;
case RelationProcessorCore:
processorCoreCount++;
// A hyperthreaded core supplies more than one logical processor.
logicalProcessorCount += CountSetBits(ptr->ProcessorMask);
break;
case RelationCache:
// Cache data is in ptr->Cache, one CACHE_DESCRIPTOR structure for each cache.
Cache = &ptr->Cache;
if (Cache->Level == 1)
{
processorL1CacheCount++;
}
else if (Cache->Level == 2)
{
processorL2CacheCount++;
}
else if (Cache->Level == 3)
{
processorL3CacheCount++;
}
break;
case RelationProcessorPackage:
// Logical processors share a physical package.
processorPackageCount++;
break;
default:
printf("\nError: Unsupported LOGICAL_PROCESSOR_RELATIONSHIP value.\n");
break;
}
byteOffset += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION);
ptr++;
}
printf("\nGetLogicalProcessorInformation results:\n");
printf("Number of NUMA nodes: %d\n"),
numaNodeCount);
printf("Number of physical processor packages: %d\n"),
processorPackageCount);
printf("Number of processor cores: %d\n"),
processorCoreCount);
printf("Number of logical processors: %d\n"),
logicalProcessorCount);
printf("Number of processor L1/L2/L3 caches: %d/%d/%d\n"),
processorL1CacheCount,
processorL2CacheCount,
processorL3CacheCount);
free(buffer);
return 0;
}
Mám Windows XP 32-bit SP3 a stejně to nejede ani po includování všech headerů
Windows Vista, Windows XP Professional x64 Edition, Windows XP with SP3 [desktop apps only]
Po kliknutí na stránku:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684197%28v=vs.85%29.aspx
zjišťuji, že na XP 32-bit není závislost. LOGICAL_PROCESSOR_RELATIONSHIP ... Je to nahov** ty Windowsovské stránky, píšou tam nejdříve že to podporuje XP SP3 a pak po bližším prostudování závislostí zas zjistím že nepodporuje. Hodina v pr**li