Visual Studio 11 Developer Preview中的BitScanForward64问题

BitScanForward64 issue in Visual Studio 11 Developer Preview

本文关键字:中的 BitScanForward64 问题 Preview Developer Studio Visual      更新时间:2023-10-16

我对用C写任何东西都是全新的。我正在编写一个执行二进制操作的辅助DLL(从c#调用)。我得到一个"标识符"BitScanForward64"是未定义的"错误。已获取32位版本。我想这是因为我创建了一个Win32 DLL。

然后我明白了64位版本可能只适用于特定的64位DLL(我假设在新项目向导上是"General"),我可能需要一个单独的32位和64位DLL。是这种情况下,或者我可以有一个DLL运行BitScanForward和BitScanForward64的内在,如果是这样,我怎么去创建它?

下面是我当前的代码:

// 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位进程中使用),如下表所示(还要注意,本质上有一个_前缀,BitScan*64函数可能需要它,它们都可以使用它)。

此链接详细介绍了在Visual Studio中创建基于x64的项目,您应该能够从中创建dll。