Question

I have a compilation problem using C++ language and IloCplex framework.

I first tried to compile the entire project using a makefile, but i got an unexpected error, with a class header call AbstractModel, so as to ensure that this error is not due to other file, i decided to just compile this class with this command :

g++ -o AbstractModel.o -c -I/path/to/cplex/include -I/path/to/concert/include -DIL_STD AbstractModel.cpp

Then i realized that i got the same error message, here is the AbstractModel class :

http://pastebin.com/B9YiqKUS

and the type.h class :

http://pastebin.com/trQ6BDBK

The error is the following :

In file included from AbstractModel.hpp:12, from AbstractModel.cpp:7: type.h:6: error: expected constructor, destructor, or type conversion before ‘typedef’ In file included from AbstractModel.cpp:7: AbstractModel.hpp:50: error: ‘Vector’ does not name a type AbstractModel.hpp:51: error: ‘Vector’ does not name a type

Any suggestions ?

P.S : Cplex works fine on this computer, i have another project with the same kind of class that compiles perfectly with the same command.

Was it helpful?

Solution

CustomType.hpp must be #included before AbstractModel.hpp because CustomType.hpp defines the typedefs that AbstractModel.hpp uses.

It is impossible to see from what you have pasted whether or not that is indeed the case.

Ideally your AbstractModel.hpp header will #include "CustomType.hpp" itself rather than relying on it being done.

OTHER TIPS

Your include guards in your header are wrong:

#ifndef CUSTOM_TYPE_H

        typedef IloNumArray Vector;
        typedef IloArray<IloNumArray> Matrix;
        typedef IloNumVarArray VariableVector;    
        typedef IloArray<IloNumVarArray> VariableMatrix;    

        #define CUSTOM_TYPE_H //This should be just under the #ifndef, not here.
#endif
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top