expected unqualified id before 'namespace'

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 


function.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <Windows.h>
#include <ing>
#include "function.h"
#include <sstream>
#include <winsock.h>
#include <MYSQL/mysql.h>
#include <ctime>
#include <vector>
using namespace std;

string getConfig(string section,string cle,string nomFichier)
{
    string valeur;
    nomFichier=".//"+nomFichier;
    GetPrivateProfileStringA(section, cle, "0", valeur, 5, nomFichier );
    return (valeur);
}


Your help will be highly appreciated.

Thank you
Last edited on
I've found the line where there is error
Great, ¿what line is it?
http://cplusplus.com/forum/articles/40071/#msg216270
When I comment the line below, I don't have the error any more.

 
std::string getConfig(std::string section,std::string cle,std::string nomFichier);


So I assume it's the faulty line.

Thanks.
It seems to work for me, but I had to comment out the ing, and mysql.h headers, as I don't have them.
Really?
I also comment out the ing and mysql.h headers and I still have the error. Which IDE do you use? I use code::blocks.
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?
Last edited on
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?

I cannot reproduce your error. gcc 4.6.1
Topic archived. No new replies allowed.