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
We can use endl in C++ but not in C. So endl runs well in C++ but if we use C, it runs error.
std::cout is used to output a value (cout = character output) std::cin is used to get an input value (cin = character input) << is used with std::cout, and shows the direction that data is moving (if std::cout represents the console, the output data is moving from the variable to the console).
Re: endl' was not declared in this scope If you meant std::endl then you have to say so (or use the using keyword). This is basic C++ and nothing at all to do with Qt. It won't compile either way because there is no QDataStream operator<<() suitable for std::endl.
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.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With