c++ - Visual Studio 11 Developer Preview 中的 BitScanForward64 问题

标签 c++ visual-studio intrinsics

我完全不熟悉用 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/

相关文章:

c++ - 应用程序段错误,仅当使用 MinGW 在 Windows 上编译时

c++ - "Hello, World!"的 "std::ref"示例是什么?

c++ - 当 QGraphicsView 或 QWidget 完成绘制或渲染时是否存在信号或事件?

c++ - 高效地拆开并重新整理 ARM NEON 中的 8 条短裤

c++ - If-else循环寻找解决方案

c# - 在为较旧的 .NET Framework 版本构建时使用较新的 C# 功能是否安全?

android - 缺少 Visual Studio 2015 所需的包

html - 当我在 visual studio 上运行我的 Angular 应用程序时出现错误。

optimization - 128 位 SSE 计数器?

c++ - 使用 Intel Intrinsics 时代码不会加速