我完全不熟悉用 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;
}
最佳答案
可以创建一个 DLL 来保存这两个操作,但它将是一个仅限 x64 的 DLL(因此只能在 64 位操作系统的 64 位进程中使用),如表 here 所示(另请注意,内部函数有一个 _
前缀,BitScan*64
函数可能需要这个,无论如何它们都可以使用它)。
This link 详细说明了在 Visual Studio 中创建基于 x64 的项目,您应该能够从中创建您的 dll。
关于c++ - Visual Studio 11 Developer Preview 中的 BitScanForward64 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8626891/