I am having a problem with trying to typedef myself a nice handy tstring (see below)
#ifndef _NISAMPLECLIENT_H_
#define _NISAMPLECLIENT_H_
#include <windows.h>
#include <stdlib.h>
using namespace std; // ERROR here (1)
#ifdef _UNICODE
#define CommandLineToArgv CommandLineToArgvW
#else
#define CommandLineToArgv CommandLineToArgvA
#endif
typedef basic_string<TCHAR> tstring; // ERROR HERE (2)
I get a compiler error when trying to compile this. The error at "ERROR here (1)" is :
Error 3 error C2871: 'std' : a namespace with this name does not exist \nisampleclient\nisampleclientdefs.h 16
If I remove the using namespace std;declaration and change ERROR HERE (2) to say typedef std::basic_string<TCHAR> tstring;then I get an error:
Error 3 error C2653: 'std' : is not a class or namespace name \nisampleclient\nisampleclientdefs.h 23
at that point instead.
Thanks in advance. :)
Include the string header (#include <string>, not string.h ;)).
Also, don't ever use:
using namespace ...
... in headers unless you want to call down the wrath of your fellow developers ;)
Side-note: in C++ most of the traditional C standard headers have counter-parts without .h extension but with a leading c. In your case #include <cstdlib> would be the better choice, although it depends on the compilers you use whether there is an actual difference.
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