Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ errors: ‘string’ does not name a type

when I compile the following files, I've got the error:

ECArgs.h:36:3: error: ‘string’ does not name a type

ECArgs.h:36: ECString value(char c);

Could somebody give me any hints for the error?

ECArgs.h

#include <list>
#include "ECString.h"

class ECArgs
{
 public:
  ECArgs(int argc, char *argv[]);
  int nargs() { return nargs_; }
  bool isset(char c);
  ECString value(char c);
  ECString arg(int n) { return argList[n]; }
 private:
  int nargs_;
  int nopts_;
  ECString argList[32];
  list<ECString> optList;
};

ECString.h

#define ECS gnu

#if ECS == gnu
#include <cstring>
#define ECString string
using namespace std;
#else
#include <bstring.h>
#define ECString string
#endif
like image 444
Xing Shi Avatar asked Dec 15 '22 13:12

Xing Shi


1 Answers

I ran into a similar error. It was due to the fact that I had left out using namespace std;

Alternatively, one has to use std::string for all occurrences of string.

like image 177
Selah Avatar answered Dec 29 '22 11:12

Selah