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).
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!
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.
yes, as Benjamin says, this will get you past the CINT parsing problems:[code]#ifndefCINT #include <boost/filesystem.hpp> #endif #include
bool exists(std::string filename);
#ifndefCINT
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.