2012-09-12 25 views
1

我想编译我的c + plus项目,使用增强库与WDK而不是VisualStudio。如何在WDK环境下使用增强库

我的电脑的操作系统是Windows7-64bit,WDK的版本是7.6和Boost库版本1.51

有一次,我编译我的源代码项目,WDK的编译器将occure错误:

e:\lib\boost_1_51_0\boost\array.hpp(72) : error C2039: 'ptrdiff_t' : is not a member of 'std' . 

整个项目的文件,内容如下:

文件来源:

TARGETTYPE=PROGRAM 
TARGETNAME=helloworld 

UMENTRY=main 
USE_MSVCRT=1 
USE_NATIVE_EH=1 

# 
# use iostream package and STL 
# 
USE_IOSTREAM=1 
USE_STL=1 
STL_VER=70 

# 
# my boost library root directory 
# 
BOOST_INC_PATH=E:\lib\boost_1_51_0 

INCLUDES=$(BOOST_INC_PATH) 
TARGETLIBS=$(SDK_LIB_PATH)\user32.lib 

SOURCES=HelloWorld.cpp 

UMTYPE=console 
UMBASE=0x4000000 

File HelloWorld.cpp:

#include <iostream> 
#include <vector> 
#include <string> 
#include <boost/array.hpp> 

void InvokeVector() 
{ 
    //invoke STL's vector 
    std::vector<std::string> vec; 
    vec.push_back("Entry "); 
    vec.push_back("of "); 
    vec.push_back("Vector"); 
    vec.push_back("……\n"); 
    //print vec 
    for (int i=0; i<vec.size(); i++) { 
     std::cout<<vec.at(i); 
    } 
} 

void InvokeBoost() 
{ 
    //invoke Boost's array<T, N> 
    boost::array<int, 3> arr = {1, 2, 3}; 
    for (int i=0; i<arr.size(); i++) { 
     std::cout<<"arr["<<i<<"]"<<"is" <<arr[i]<<std::endl; 
    } 
} 

int main() 
{ 
// InvokeVector(); //run normally 
    InvokeBoost(); //it will occure an error 
    return 0; 
} 

你能教我如何解决这个问题吗?任何帮助将不胜感激!

+0

我怀疑你可以使用提升“为是” WDK,请访问以下链接:http://stackoverflow.com/questions/718309/使用boost-in-wdk-build-environment-for-applications。但是,您可以尝试修补所需的增强库。 –

+0

您的项目是驱动程序吗?如果不是,你为什么要用WDK构建它? –

+0

亲爱的Igor R:我正在开发一个dokan图书馆用户模式应用程序,dokan图书馆要求使用WDK构建,但vs2010,所以我混淆了如何在WDK环境中构建我的dokan应用程序。 – Jerry

回答

0

简短回答:没有。

但是你可以移植一些。

这是很说明如下:The NT Insider:Guest Article: C++ in an NT Driver

One of the main problems with C++ in the kernel is that most of the "nice" features of the language are not directly available in that mode. Some are easy to recreate and we will see how to do that. However, some features should be forgotten such as C++ exceptions, which are not the same as kernel exceptions.

Such features have to be forgotten simply because there is no support for them in kernel mode. Translation: does not compile. If you have the time and energy you may attempt to port them to kernel mode, but frankly, exceptions are too slow for kernel mode. This will have an impact on your C++ coding style, which is something you should keep in mind.

+0

我想在VS2010中运行Dokan库的mirror.c示例,但失败了。所以我按照Dokan的官方选项在WDK中构建镜像示例,但是我的用户模式应用程序中包含一些C++语言,这就是为什么我问以前是否有人让WDK支持C++。 http://dokan-dev.net/en/docs/ – Jerry

0

更长的答案 - 是

只需添加

的typedef INT ptrdiff_t的;

之前在boost头文件拉动和一切都会好起来的基本boostness