Reputation: 9624
I hope someone can help me on this small problem as I'm getting no where at all. Firstly, heres the code:
#include<string>
#include<iostream>
#include<Windows.h>
using namespace std;
extern "C"
{
#include<hidsdi.h>
#include<SetupAPI.h>
}
int main()
{
int iQuit;
cout << "Testing Program" << endl;
return 0;
}
It won't let me use the std stuff (ie cout, cin, endl etc). It will only allow me to use it when I take out all the extern "C" code... Why is that? And is there a way around this?
EDIT: Sorry, forget to tell you the exact error: It says identifier "cout" is undefined
Thanks
Upvotes: 6
Views: 1401
Reputation: 9624
I've found out the problem, I weren't adding the directories in the correct order in VC++ Directories.
The order should be:
C:\WinDDK\7600.16385.1\inc\ddk
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
C:\WinDDK\7600.16385.1\inc\api
$(WindowsSdkDir)include
$(FrameworkSDKDir)\include
Don't know why it needs to be in this order, but it works now... Very strange...
Upvotes: 1
Reputation: 612993
There is something wrong with your compilation environment. There is nothing wrong with that code. It compiles and runs fine.
In a comment to the question you say:
I'm learning to write a driver so I can do stuff with my devices like keyboards and mouses, so I'm using the WDK. Correct me if I'm wrong, but I thought you need to use extern "C" to use those header files?
In fact you should simply write code in C rather than C++ for driver development.
Upvotes: 3