Hi all,
I am writing an application in C++ and I have the error "expected unqualified id before 'namespace'" when I try to compile it. I've found the line where there is error but I don't know what exactly I did bad. Here is a part of my code.
function.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#ifndef FUNCTION_H_INCLUDED
#define FUNCTION_H_INCLUDED
#include <string>
#include <vector>
/*
*Ensemble des fonctions utilisées par les différentes classes
*
*/
std::vector <std::string> extractSbstr(std::string chaine,char charSeparateur);
std::string getConfig(std::string section,std::string cle,std::string nomFichier);
std::string convertIntString(int entier);
int convertStringInt(std::string chaine);
int mysqlconnect(std::string DB);
struct tm setDate(int jour,int mois,int an,int heur,int mn,int s);
int getYear();
#endif // FUNCTION_H_INCLUDED
I'm using Visual Studio 2010. Perhaps rearrange the order of your #include statements. Maybe move "function.h" to just below Windows.h, or try it as the last #include. Just a thought.
What happens if you do not include "function.h" in "function.c"? Does that help?
In general, compilers tells you in that line is the error. Sometimes you've got to look up (maybe forgot a semicolon in previous line or a class declaration)
1 2
//expected unqualified id before 'namespace'
std::string getConfig(std::string section,std::string cle,std::string nomFichier);
I don't see anything wrong with that line.
However (maybe unrelated) struct tm setDate(int jour,int mois,int an,int heur,int mn,int s); ¿what is a 'tm' and where is defined? ¿and what does the struct at the begginning of the line?