And to answer the follow up question (“why do I have to do that?”), this allows you to write code which will compile to be run on older versions of windows that don’t have that particular API. If you’re writing a program that’s supposed to run on Win98, then you want to get an error if you try to use an API that doesn’t exist there. You use the _WIN32_WINNT macro to indicate the minimum platform you’re writing for.
[assuming you’re using Visual Studio…]
A good way to troubleshoot this if you’re really stumped is to go into the properties dialog for the source file, look at the compiler settings, and look at the bottom of the window where it shows the actual command line it is going to use to compile. Copy that command line, open a “Visual Studio Command Prompt”, cd to the directory with your source file, and paste the command line into your shell. You should get the exact same error. Now paste the command line into notepad, add a /P option to it, and paste it into your shell again. This time, the compiler will create a .i file that matches your .cpp or .c file (e.g. foobar.cpp -> foobar.i). This file will be very large, but also very informative. It is what results from running your source file through the preprocessor, and you can see what all the macros got converted into, and you can see what parts of header files have been skipped over because they got ifdef’d out. Examining this file should give you clues for determining if your _WIN32_WINNT macro is set correctly.
I have just gone into Visual Studio and created a console app from the source linked above and it compiled for me with no problems at all. Looking at winbase.h, the only #define I see around DeleteVolumeMountPoint is the version one mentioned previously.
I suspect that something is set up in your search paths so that an older version of winbase.h is being used.
I haven’t had a lot of time to work on it. But, I did a build with everything I know of pointing in the right direction, and it still didn’t work. I think the next thing I will try is shipping the “old” .h files to some other country before I try another build!!!
One of the problems is, I have several compilers on this machine. We have to support all kinds of systems at several different version levels.
This isn’t a big mystery if you just do some legwork. Go into the properties dialog for the .cpp file in question. Look at the compiler settings, particularly the bottom part that shows the actual command line that compiles the file. One of the options on the command line will be responsible for including an incorrect include path (probably a /I option) that gets you the wrong winbase.h (or possibly some other wrong header which fails to include winbase.h – you can find out for sure if you follow my advice and painstakingly plow through the preprocessor output). Figure out which option is causing this, and then figure out which thing in the compiler settings (e.g. “additional include directories”) is causing that option to be added to the command line.