Reputation: 11936
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
static xmlDocPtr importSettings(char file[]="CsSettings.xml"){}
That's not so complicated, why does it always throw this error?
test.c:3: error: expected ‘;’, ‘,’ or ‘)’ before ‘=’ token
Am I compiling it wrong?
Upvotes: 1
Views: 1520
Reputation: 41388
C doesn't have default parameter values. You need to compile your file as C++.
Edit:
So you don't want to use C++. (Good, because I don't want to use C++, either.) Here's one reasonable way to do the same thing:
static xmlDocPtr importSettings(char file*)
{
if (file == NULL)
{
file = "CsSettings.xml";
}
/* etc. */
}
This way, if you want to use the default, just pass NULL to the import settings.
Another option is to add #define DEFAULT_XML_FILE "CsSettings.xml"
somewhere in your header, and then require callers to pass DEFAULT_XML_FILE
if they want to use the default.
Upvotes: 6
Reputation: 1075209
C doesn't have default values on arguments. C++ has them, though.
Upvotes: 4