views:

861

answers:

3

I am using the Windows Driver Kit (WinDDK 6001.18001) to build my userspace application rather than Visual Studio 2005. I am taking this approach because we also have to build driver components, so I'd prefer to have a single build environment to build everything. Microsoft itself uses this approach for several products.

This was working fine until I started using Boost 1.38.0. I'm not using C++ in the kernel mode components, just the userspace applications. In C++ code, it's natural to use the boost libraries. Unfortunately, the WDK doesn't agree.

The first error I noticed is that "#include <cstddef>" doesn't put ptrdiff_t in the std namespace, as seems required by Annex D. Working around this left several errors in boost\lambda\detail\operator_return_type_traits.hpp about error C2976: 'std::basic_string' : too few template arguments. It appears redundant with iostream.

Has anyone successfully gotten the combination of Boost, iostream, and the WDK to work together?

My sources file:

TARGETNAME=foobar
TARGETTYPE=PROGRAM

USE_MSVCRT = 1
USE_STL = 1
USE_ATL = 1
ATL_VER = 30
STL_VER = 70
USE_NATIVE_EH = 1 
USE_IOSTREAM = 1

SUBSYSTEM_VERSION = 5.02

C_DEFINES = \
    -D_MT \
    -DWIN_32 \
    -DWIN32  \
    -D_WINDOWS \
    -DNT \
    -D_WIN32_DCOM \
    -DUNICODE \
    -D_UNICODE \
    -D_ATL_NO_DEBUG_CRT # because we are using USE_MSVCRT=1 

SOURCES=service.cpp

INCLUDES=\
    $(BOOST_INC_PATH)

TARGETLIBS=\
    $(SDK_LIB_PATH)\ole32.lib \
    $(SDK_LIB_PATH)\oleaut32.lib \
    $(SDK_LIB_PATH)\uuid.lib \

UMTYPE=console
UMBASE=0x400000

service.cpp:

#include <iostream>
#include <cstddef>

namespace std {
        typedef ::ptrdiff_t ptrdiff_t; // DDK C++ workaround
}

#include <boost/lambda/lambda.hpp>

int __cdecl main() {
    return 0;
}
+1  A: 

Interesting question. Using STL as-is was a challenge in itself with the WDK. I have not ventured beyond. I can give this a try. Remember, the WDK has it's own compiler which is not the same as your VS2005/VS2008 complier (check the version numbers). It is highly likely there are a few bugs here and there.

Note, that USE_MSVCRT=1 and USE_STL=1 didn't gel well (at least for WDK 6001).

dirkgently
Thanks for sharing your experience. I tried using USE_LIBCMT=1 instead of msvcrt, but problems remained. Given that even STL is problematic, I'm going have to reconsider using the WDK.
We build our app part w/ VS200x and the driver only with the WDK. Note, the ddkbuild utility is just a wrapper batch file over the commandline arguments (I use it all the time) and it probably won't help sort out compiler issues.
dirkgently
I suggested to use ddkbuild for building driver and using standard vs project to build the application. You will have a solution that one of the projects (driver) will be build with custom build using ddkbuild and second one (Boost) will be build standard way.
Ilya
A: 

I would suggest going different way, i.e compiling driver from VS200.x using this (ddkbuild) nice tool.

Being myself a command line person and using makefiles everywhere possible, i find build utility not useful for complex project.There is tons of limitation within MS build utility and i would recommend using VS environment for compiling your project.

I'm not sure if there is a howto in the ddkbuild, but it's straight forward to integrate ddkbuild.bat into VS custom build option.

Ilya
Thanks, I'll probably go this route.
IMMHO, The ddkbuild is of little help when you have a compile error.
dirkgently
I'm not 100% sure but i think it's possible to display errors and warnings in the VS log, but any way it's same as using build from command line you need to open log files to see the errors.
Ilya
@Ilya: By default, it displays the output as it'd with any custom build tool. However, you won't get the 'click to go to erroneous line' functionality or a grouping of errors etc. If you are willing to go that extra mile, yes, even that is possible.
dirkgently
If you are choose not going that extra mile (like me:) ), you still in better position than a pure command line build, i.e the situation is not worse with driver and much better with user mode application.
Ilya
+1  A: 

Boost may already include a work-around for your issues, but isn't applying it because it doesn't recognise the compiler you're using (probably because drivers rarely use boost).

Try examining (and possibly editing) boost/config/select_compiler_config.hpp and boost/config/compiler/visualc.hpp to make sure the compiler workarounds for MSVC are enabled.

Joe Gauterin