I encountered a weird error when building my code:
Before I show you what the error was, I'd like to show you what the code is doing. This is a node class for my little cmd project, each node is a file/folder. I wrote a function to show the info of the node.
// Node.h
#include <string>
#include <memory>
using namespace std;
typedef bool NODE_TYPE;
#define FILE true
#define DIR false
class Node
{
private:
string _node_name;
NODE_TYPE _node_type;
string _create_date;
string _create_user;
weak_ptr<Node> _parent;
shared_ptr<Node> _sibling;
shared_ptr<Node> _child;
public:
/*Constructors, Destructors and other functions*/
const string toString();
};
// Node.cpp
#include "Node.h"
#include <string>
#include <sstream>
using namespace std;
const string Node::toString()
{
ostringstream buffer;
buffer << ... // the data member of Node
return buffer.str();
}
I wrote a test in main.cpp
, and when I say g++ Node.cpp main.cpp -Wall -std=c++11
, here's the error:
In file included from Node.cpp:6:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/sstream:184:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/istream:163:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/ostream:138:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/ios:214:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:40:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/xlocale.h:93:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/xlocale/_stdio.h:32:33: error: expected expression
int fprintf_l(FILE * __restrict, locale_t __restrict, const char * __restrict, ...)
Errors like this are 21 more, I guess there was something wrong with SDK, so I reinstalled it, however still no work. Could anyone help me?