Windows 仅提供直到 Windows Vista 的 GetTickCount,并且从该操作系统开始还提供 GetTickCount64。如何通过调用不同的函数来编译C程序?
如何让C编译器检查是否在包含的头文件中声明了一个函数,并根据该特定函数是否可用来编译代码的不同部分?
#if ??????????????????????????????
unsigned long long get_tick_count(void) { return GetTickCount64(); }
#else
unsigned long long get_tick_count(void) { return GetTickCount(); }
#endif
寻找工作示例文件而不仅仅是提示。
编辑:我在(64 位)Windows 7 RC 上使用 MinGW 的 gcc 3.4.5 尝试了以下操作,但没有帮助。如果这是 MinGW 问题,我该如何解决这个问题?
#include <windows.h>
#if (WINVER >= 0x0600)
unsigned long long get_tick_count(void) { return 600/*GetTickCount64()*/; }
#else
unsigned long long get_tick_count(void) { return 0/*GetTickCount()*/; }
#endif