Kompilierfehler bei boost::regex



  • Hallo,

    ich habe ein laengeres, kompilierfaehiges Programm, bei dem ich boost::regex mittels

    #include <boost/regex.hpp>
    

    in main.cc einbinde. Der Anfang von main.cc sieht wie folgt aus (Details sind hier nicht wichtig):

    #include "standard.h"
    
    #include "constants.h"
    #include "dot.h"
    #include "error.h"
    #include "files.h"
    #include "hook_pos.h"
    #include "logging.h"
    #include "MCMC.h"
    #include "nd.h"
    #include "random.h"
    #include "sim_tree.h"
    #include "test.h"
    #include "tip_seqs.h"
    #include "tree.h"
    
    #include <boost/regex.hpp> 	
    
    using namespace boost::program_options;
    
    int main(int argc, char** argv) {
        ...
    }
    

    Des Weiteren habe ich ein Header-File standard.h, in dem ich alles habe, was man haeufig braucht (um vorkompilierte Header nutzen zu koennen, binde ich es in fast allen Files als erstes ein). standard.h sieht wie folgt aus (Details sind hier nicht wichtig):

    #ifndef STANDARD_H_
    #define STANDARD_H_
    
    #include <fstream>
    #include <iostream>
    #include <sstream>
    
    #include <iomanip>
    
    #include <list>
    #include <map>
    #include <set>
    #include <string>
    #include <vector>
    
    #include <cstdio>
    #include <cmath>
    #include <ctime>
    #include <unistd.h>
    
    #include <gsl/gsl_blas.h>
    #include <gsl/gsl_cdf.h>
    #include <gsl/gsl_errno.h>
    #include <gsl/gsl_integration.h>
    #include <gsl/gsl_linalg.h>
    #include <gsl/gsl_math.h>
    #include <gsl/gsl_matrix.h>
    #include <gsl/gsl_min.h>
    #include <gsl/gsl_randist.h>
    #include <gsl/gsl_roots.h>
    #include <gsl/gsl_sf_gamma.h>
    
    #include <boost/algorithm/string.hpp>
    #include <boost/assign/list_of.hpp>
    #include <boost/assign/std/vector.hpp>
    #include <boost/checked_delete.hpp>
    #include <boost/filesystem.hpp>
    #include <boost/foreach.hpp>
    #include <boost/format.hpp>
    #include "boost/lexical_cast.hpp"
    #include "boost/multi_array.hpp"
    #include <boost/operators.hpp>
    #include <boost/program_options.hpp>
    #include <boost/scoped_ptr.hpp>
    #include <boost/shared_ptr.hpp>
    #include <boost/tokenizer.hpp>
    #include <boost/tuple/tuple.hpp>
    #include <boost/utility.hpp>
    #include <boost/variant.hpp>
    #include <boost/weak_ptr.hpp>
    
    #include <log4cxx/basicconfigurator.h>
    #include <log4cxx/helpers/exception.h>
    #include <log4cxx/logger.h>
    #include <log4cxx/propertyconfigurator.h>
    
    #include "bool.h"
    #include "io_contnr.h"
    #include "rvec.h"
    
    using namespace boost;
    using namespace boost::assign;
    using namespace boost::filesystem;
    using namespace log4cxx;
    using namespace log4cxx::helpers;
    using namespace std;
    
    #define FOREACH         BOOST_FOREACH
    #define REVERSE_FOREACH BOOST_REVERSE_FOREACH
    
    extern shared_ptr<ofstream> fout;
    
    template <class O, class V> typename V::result_type apply_visitor(V& v, O& o)
    {
        o.accept(&v);
        return v.result();
    }
    
    template <class O, class V> typename V::result_type apply_visitor(V& v, O* o)
    {
        o->accept(&v);
        return v.result();
    }
    
    #endif
    

    Wenn ich nun

    #include <boost/regex.hpp>
    

    aus main.cc nach standard.h verschiebe, erhalte ich die folgende Fehlermeldung. Dabei ist Rev_Nd eine meiner Klassen,

    Base_Nd<Rev_Nd, Rev_NC, Rev_Tree>
    

    und

    Prob_Nd<Rev_Nd, Rev_NC, Rev_Tree>
    

    sind Instanzen von Klassentemplates, aus denen Rev_Nd abgeleitet ist.

    **** Build of configuration Debug for project GenRecon ****
    
    make all 
    Building file: ../main.cc
    Invoking: GCC C++ Compiler
    g++ -I../../../libs/boost -I../../../libs/gsl/include -I../../../libs/log4cxx/include -I../ -I../src -I../src/classification -I../src/IO -I../src/node -I../src/tree -O0 -g3 -c -fmessage-length=0 -ansi -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cc"
    In file included from ../main.cc:10:
    /usr/include/c++/4.3/bits/stl_iterator_base_types.h: In instantiation of »std::iterator_traits<Rev_Nd>«:
    ../../../libs/boost/boost/regex/v4/iterator_traits.hpp:116:   instantiated from »boost::re_detail::regex_iterator_traits<Rev_Nd>«   // ???
    ../src/node/base_nd.h:27:   instantiated from »Base_Nd<Rev_Nd, Rev_NC, Rev_Tree>«
    ../src/node/base_nd.h:91:   instantiated from »Prob_Nd<Rev_Nd, Rev_NC, Rev_Tree>«
    ../src/node/nd.h:26:   instantiated from here
    /usr/include/c++/4.3/bits/stl_iterator_base_types.h:133: Fehler: invalid use of incomplete type »class Rev_Nd«
    ../src/IO/dot.h:8: Fehler: forward declaration of »class Rev_Nd«
    /usr/include/c++/4.3/bits/stl_iterator_base_types.h:134: Fehler: invalid use of incomplete type »class Rev_Nd«
    ../src/IO/dot.h:8: Fehler: forward declaration of »class Rev_Nd«
    /usr/include/c++/4.3/bits/stl_iterator_base_types.h:135: Fehler: invalid use of incomplete type »class Rev_Nd«
    ../src/IO/dot.h:8: Fehler: forward declaration of »class Rev_Nd«
    /usr/include/c++/4.3/bits/stl_iterator_base_types.h:136: Fehler: invalid use of incomplete type »class Rev_Nd«
    ../src/IO/dot.h:8: Fehler: forward declaration of »class Rev_Nd«
    /usr/include/c++/4.3/bits/stl_iterator_base_types.h:137: Fehler: invalid use of incomplete type »class Rev_Nd«
    ../src/IO/dot.h:8: Fehler: forward declaration of »class Rev_Nd«
    

    Das verstehe ich nun ueberhaupt nicht, denn:

    • main.cc bindet standard.h als erstes ein und main.cc ist der einzige Ort, wo ich boost::regex brauche
    • Wie kommt die Zeile
    instantiated from »boost::re_detail::regex_iterator_traits<Rev_Nd>«
    

    zu stande? regex wird von Rev_Nd nicht benutzt und hat damit ueberhaupt nichts zu tun (Rev_Nd ist eine Klasse, die bestimmte Knoten in einen Graphen repraesentiert).

    Faellt irgendjemanden hierzu was ein? Insbesondere: Wie gehe ich solche Probleme am besten an? Die mir bekannten Standard-Methoden zum Finden von Komplierfehler helfen mir hier nicht weiter.

    Nachtrag: Wenn ich uebrigens

    #include <boost/regex.hpp>
    

    sowohl in main.cc als auch standard.h habe, kann ich kompilieren.


Anmelden zum Antworten