BitScanForward64 issue in Visual Studio 11 Developer Preview

拟墨画扇 提交于 2019-12-12 01:13:52

问题


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.

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?

Here is my current code:

// 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;
}

回答1:


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).

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



来源:https://stackoverflow.com/questions/8626891/bitscanforward64-issue-in-visual-studio-11-developer-preview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!