c++visual-studio-2017string-function

Why identifier 'strlen' is undefined?


I am writing a program in C++. When I use the strlen function, it is underlined by a red line. Although the project is built without errors. This is how I use this function. (By the way, strcpy is also underlined).

Exception::Exception(int _Line, char* _File, char* _Func, char* _Desc)
{
  Line = _Line;
  int size = strlen(_File) + 1;
  File = new char[size];
  strcpy(File, _File);
  Func = new char[size];
  strcpy(Func, _Func);
  Desc = new char[size];
  strcpy(Desc, _Desc);
}

And I declared <cstring> library at the beginning of the file. Please tell me how I can fix this?


Solution

  • The system that underlines the code in the VS editor, called IntelliSense, does not use the same code as the compiler itself (or at least did not a few years ago when I used it last time). Sometimes it gets confused.

    Try std::strlen instead, reorganizing the code, the includes, or something else.