我对用 C 编写任何东西都是全新的。我正在编写一个执行二进制操作的辅助 DLL(从 C# 调用)。我收到“标识符“BitScanForward64”未定义”错误。32 位版本可用。我认为这是因为我创建了一个 Win32 DLL。
然后我恍然大悟,64 位版本可能仅适用于特定的 64 位 DLL(我在新项目向导中假设为“常规”),并且我可能需要单独的 32 位和 64 位 dll。是这种情况,还是我可以拥有一个同时运行 BitScanForward 和 BitScanForward64 内在函数的 DLL,如果是这样,我该如何创建它?
这是我当前的代码:
// C Functions.cpp : Defines the exported functions for the DLL application.
#include "stdafx.h"
//#include <intrin.h>
//#include <winnt.h>
int _stdcall LSB_i32(unsigned __int32 x)
{
DWORD result;
BitScanForward(&result, x);
return (int)result;
}
int _stdcall MSB_i32(unsigned __int32 x)
{
DWORD result;
BitScanReverse(&result, x);
return (int)result;
}
int _stdcall LSB_i64(unsigned __int64 x)
{
DWORD result;
BitScanForward64(&result, x);
return (int)result;
}
int _stdcall MSB_i64(unsigned __int64 x)
{
DWORD result;
BitScanReverse64(&result, x);
return (int)result;
}