【问题标题】:BitScanForward64 issue in Visual Studio 11 Developer PreviewVisual Studio 11 开发者预览版中的 BitScanForward64 问题
【发布时间】:2012-01-27 10:52:32
【问题描述】:

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

【问题讨论】:

标签: c++ visual-studio intrinsics


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-20
    • 1970-01-01
    • 2011-11-18
    • 2011-12-05
    • 2012-04-04
    • 1970-01-01
    • 2018-10-08
    • 1970-01-01
    相关资源
    最近更新 更多