0

我对用 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;
}
4

1 回答 1

2

可以创建一个 DLL 来保存这两个操作,但它将是一个仅 x64 的 DLL(因此只能在 64 位进程中的 64 位操作系统上使用),如此处的表所示另请注意intrisics 有一个_前缀,BitScan*64函数可能需要这个,无论如何它们都可以使用它)。

此链接详细说明了在 Visual Studio 中创建基于 x64 的项目,您应该可以从中创建 dll。

于 2011-12-24T22:37:36.100 回答