Visual Studio 11开发者预览中的BitScanForward64问题 [英] BitScanForward64 issue in Visual Studio 11 Developer Preview

查看:809
本文介绍了Visual Studio 11开发者预览中的BitScanForward64问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完全是新写C的。我正在写一个辅助DLL(从C#调用)来执行二进制操作。我得到一个标识符BitScanForward64未定义的错误。提供32位版本。我想这是因为我创建了一个Win32 DLL。

I am totally new to writing anything in C. I am writing a helper DLL (to be called from C#) that performs binary manipulation. I get an 'identifier "BitScanForward64" is undefined' error. The 32-bit version is available. I figure this is because I created a Win32 DLL.

然后我明白,64位版本可能只有一个特定的64位DLL(我假设一般对新的项目向导),我可能需要一个单独的32位和64位的DLL。是这种情况,或者我可以有一个DLL运行BitScanForward和BitScanForward64内在函数,如果是这样,我如何去创建它?

It then dawned on me that the 64 bit version may only be available to a specific 64 bit DLL (I assume "General" on the new project wizard), and that I may need a separate 32 bit and 64 bit dll. Is this the case, or can I have a single DLL that runs both the BitScanForward and BitScanForward64 intrinsics, and if so, how do I go about creating it?

这里是我当前的代码:

// 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位操作系统上使用),如表中所示这里(还要注意,intrisics有一个 _ 前缀, BitScan * 64 函数可能需要这个,他们都使用它,而不管)。

It is possible to create a DLL to hold both these operations, but it would then be an x64 only DLL (and thus usable only on a 64-bit OS in a 64-bit process), as shown in the table here (also note that the intrisics have an _ prefixed to them, the BitScan*64 functions might require this, they all work with it regardless).

此链接详细信息在Visual Studio中创建一个基于x64的项目,从中你应该能够创建你的dll。

This link details creating a x64 based project in Visual Studio, from which you should be able to create your dll.

这篇关于Visual Studio 11开发者预览中的BitScanForward64问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆