Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Probs with GCC and Static class member functions...

Status
Not open for further replies.

VBDotNetProgrammer

Programmer
Jul 9, 2003
50
0
0
GB
Hi all,

Im having trouble compiling an application which compiles fine under VC6 but not with GCC.

The error im getting is:

Xml.h:34: error: `static' can only be specified for objects and functions
make: *** [main.o] Error 1

The offending piece of code is:

class CXMLParser
{
public:
static bool GetXMLTagValues(string xmlFileString, string tagName, vector<string> *vect);

static string GetXMLTagValue(string xmlFileString, string tagName);

// Loads XML ruleset file into memory
static string LoadXMLFile(string xmlFilename);

static bool IsTagPresent(string xmlString, string tagName);
static string DeleteTagValue(string xmlString, string tagName);
static bool VerifyWellFormedness(string xmlToVerify);
};

Ive left some of the class def out but it is complaining about the last function def shown. Im i declaring static members incorrectly. VC6 doesnt mind but GCC doesnt seem to like it.

Any ideas?

Thanks
 
Obviously your gcc understands C only, not C++.
 
Haha no its perfectly fine with the c++ it just doesnt seem to like my use of static.

Any thought from someone? Come on guys im desperate and I dont want to revert back to the non-static design as this saves mem because quite a few objects make use of this functionality.

Thanks
 
This problem is fixed, basically I ommitted it from the above example but i preceded the class definition with static i.e.

static CXMLParser
{

and that was the cause. For thos of you who may be interested.

Rgrds
 
Hehe, what's the language with static CXMLParser {...} legal construct?..
 
This problem is fixed, basically I ommitted it from the above example but i preceded the class definition with static i.e.

static CXMLParser
{

and that was the cause. For thos of you who may be interested.

Rgrds
 
Hmm for some reason I seem to have double posted.

ArkM:
Believe it or not it was VC++6! lol

GCC seems to bring up loads of warnings about things such as comparisons between signed and unsigned int's so on the whole seems a lot strickter (which can only be a good thing)

Rgrds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top