1

I wanna to compile my c plus plus project that using boost library with WDK rather than VisualStudio.

My computer's OS is Windows7-64bit, the WDK version is 7.6 and boost library version is 1.51

Once I compile my source code project, the WDK compiler will occure an error:

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

Whole project's file contents are as follow:

File sources:

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

Could you please teach me how to solve this problem? Any help will be greatly appreciated!

Jerry
  • 13
  • 3
  • I doubt you can use boost "as is" with WDK, see the following link: http://stackoverflow.com/questions/718309/using-boost-in-wdk-build-environment-for-applications . However, you can try and patch the boost libraries you need. – Igor R. Sep 12 '12 at 09:28
  • Is your project a driver? If not, why would you want to build it using the WDK? – Carey Gregory Sep 12 '12 at 15:38
  • Dear Igor R: I'm developing an dokan library user mode application, the dokan library ask for build with WDK but vs2010, so, I confusing how to build my dokan app in WDK environment. – Jerry Sep 13 '12 at 06:39

2 Answers2

0

Short answer: No.

But you can port some.

It's well explained here : 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.

Peter
  • 1,048
  • 10
  • 23
  • I want to run Dokan library's mirror.c sample in VS2010, but failed. So I follow the Dokan's official option to build mirror sample in WDK, but my user-mode app contain some C++ languange in it, and it's why I ask if there was someone make WDK support C++ before. http://dokan-dev.net/en/docs/ – Jerry Sep 17 '12 at 03:02
0

longer answer - yes

just add

typedef int ptrdiff_t;

before pulling in boost headers and all will be well for basic boostness