Thanks for the prompt response.
Yes, that is the proble, but since each declaration file has 'inclusion
guards' I did not expect it to be a problem. What can I do to solve
this problem?
Again thanks so much!
Here is a posting with a little more info.
--- main.c ---
#include <cstdlib>
#include <iostream>
#include <string>
#include <limits.h>
#include <complex.h>
#include "../strtools/strtools.hpp"
#include "../gnu_io/gnu_io.hpp"
#include "person.hpp"
using namespace std;
void TestConstructors();
void TestingSetters();
int Write(jme::Person&);
int main(int argc, char *argv[])
{
//TestConstructors();
TestingSetters();
system("PAUSE");
return EXIT_SUCCESS;
}
int Write(jme::Person& obj){
try{
//file IO handler
----
}
void TestingSetters(){
//testing all the setters and getters for class Person
}
void TestConstructors(){
//Testing all the contructors for class Person
}
--- Person.hpp ----
#ifndef JME_PERSON_HPP
#define JEM_PERSON_HPP
#include <cstring>
#include <string>
#include "../exception/exception.hpp"
#include "../strtools/strtools.hpp"
#include "../name/name.hpp"
#include "../address/address.hpp"
#include "../email/email.hpp"
#include "../phone/phone.hpp"
#include "../url/url.hpp"
#include "../io_base/io_base.hpp" //<<<==== ??
#include "../gnu_io/gnu_io.hpp"
#include "../index/index.hpp"
#include <deque>
#include <algorithm>
#include <fstream>
namespace jme{
class Person{
// A whole bunch of variables and functions go here
};
}
--- person.cpp ---
#ifndef JME_PERSON_HPP
#include "person.hpp"
#endif
// A whole bunch of variable are assigned values through
// the uses of setters and getters.
--- io_base.hpp --
#ifndef JME_IO_BASE_H
#define JME_IO_BASE_H
#include <fstream>
#include <string>
#include "../exception/exception.hpp"
#include "../strtools/strtools.hpp"
#include "../name/name.hpp"
#include "../date/date.hpp"
#include "../money/money.hpp"
#include "../address/address.hpp"
#include "../email/email.hpp"
#include "../phone/phone.hpp"
#include "../url/url.hpp"
#include "../index/index.hpp"
#include "../person/person.hpp" //<<<<==== ??
Like most projects, this class belongs to a group library. When
testing the class as an isulated class, the program compiles without
any problems, however, when adding rest to the library to the test
program, the compiler complains sying that class Person has been
previously declared. I know, for a fact, that there is no redeclaration
of class Person. What I believe is happening is that I forgot to close
a bracket in a try block or anywhere else, but the compiler detects the
problem as being a redefined of the class Person.
This is the exact error code message:
Compiler: Default compiler
Building Makefile: "C:\Jamiil\dev\c++\jme\person\Makefile.win"
Executing make...
make.exe -f "C:\Jamiil\dev\c++\jme\person\Makefile.win" all
g++.exe -D__DEBUG__ -c main.cpp -o main.o -I"C:/GnuWin32/INCLUDE"
-I"C:/GnuWin32/INCLUDE/GTK-2.0" -I"C:/GnuWin32/INCLUDE/GLIB-2.0"
-I"C:/GnuWin32/INCLUDE/PANGO-1.0" -I"C:/GnuWin32/INCLUDE/CAIRO"
-I"C:/GnuWin32/INCLUDE/ATK-1.0" -I"C:/GnuWin32/INCLUDE/GTKGLEXT-1.0"
-I"C:/GnuWin32/LIB/GTK-2.0/INCLUDE"
-I"C:/GnuWin32/LIB/GLIB-2.0/INCLUDE"
-I"C:/GnuWin32/LIB/GTKGLEXT-1.0/INCLUDE"
-I"C:/GnuWin32/INCLUDE/LIBGLADE-2.0" -I"C:/GnuWin32/INCLUDE/LIBXML2"
-fexceptions -fverbose-asm -pg -g3
In file included from main.cpp:9:
person.hpp:26: error: redefinition of `class jme::Person'
.../gnu_io/..\io_base\/../person/person.hpp:26: error: previous
definition of `class jme::Person'
make.exe: *** [main.o] Error 1
Execution terminated
Thanks!!
iftekhar wrote:
Jamiil
I guess the problem is with header file inclusion. are you including
the Person header in the io_base cpp and io_base header in the Person
cpp ? and does the person header has header guard? check these first.
please post the full gcc error
hope it helps