Boost incompatibility?

Hi,

I’m trying to use the boost::filesystem::exists function in my code, but I can’t get it to compile with CINT (which is necessary to use all of that through pyROOT in the end).

I made a test file:

[code]
#include <boost/filesystem.hpp>

bool exists(std::string filename);

bool exists(std::string filename){
return boost::filesystem::exists(filename);
} [/code]

And the compilation fails with:

root [0] .L boost_filesystem.cpp+ In file included from /usr/include/boost/filesystem/path_traits.hpp:24:0, from /usr/include/boost/filesystem/path.hpp:25, from /usr/include/boost/filesystem.hpp:16, from /home/abis_m/lab/sandbox/./boost_filesystem.cpp:1, from /tmp/rootcint_5viUzl.h:3, from /tmp/DSdfRy_cint.cxx:1: /usr/lib/root/cint/cint/include/cwchar:9:20: fatal error: cwchar.h: No such file or directory compilation terminated. Error: external preprocessing failed. :0: !!!Removing /home/abis_m/lab/sandbox/boost_filesystem_cpp_ACLiC_dict.cxx /home/abis_m/lab/sandbox/boost_filesystem_cpp_ACLiC_dict.h !!! Error: /usr/bin/rootcint: error loading headers... Error in <ACLiC>: Dictionary generation failed!

What am I doing wrong?

I find out that boost/filesystem.hpp includes a version of cwchar that is different from what the CINT finds in /usr/lib/root/cint/cint/include/cwchar

I tried to point the CINT to the boost version, but they are incompatible, do you know of any workaround?

[quote=“Matthaeus”]

#include <boost/filesystem.hpp>

bool exists(std::string filename);

bool exists(std::string filename){
    return boost::filesystem::exists(filename);
}

What am I doing wrong?[/quote]

Did you already try to confine code which needs Boost into some space that
isn’t seen by CINT? In the example you gave the signature of exists uses no
Boost types and CINT should be able to handle a std::string just fine, so
you could put exists's declaration into the header (which needs to be seen by
CINT if you want dicitionaries) and it’s definition in some independently
compiled source file.

Benjamin

Hi,

yes, as Benjamin says, this will get you past the CINT parsing problems:[code]#ifndef CINT
#include <boost/filesystem.hpp>
#endif
#include

bool exists(std::string filename);

#ifndef CINT
bool exists(std::string filename){
return boost::filesystem::exists(filename);
}
#endif[/code]
Note that the body of the function will still be seen by the compiler after CINT is done parsing, since the whole file will be #included in the generated code for the dictionary.

Of course, you still need to link with the relevant boost libs at that point (or pre-load them with gSystem->Load()) for the ACLiC compilation to succeed.

Cheers,
Wim