Miniball / MiniballSort

Sort code for Miniball data using the new FEBEX/MIDAS DAQ
3 stars 11 forks source link

Compatibility issues with std::make_unique in ROOT version 6.12/06 #27

Open lyubenkod opened 2 months ago

lyubenkod commented 2 months ago

`[lyubenk@blacknuc MiniballSort]$ make c++ -c -Wall -Wextra -pthread -std=c++11 -m64 -I/usr/local/root612/include -g -fPIC -O3 -DUNIX -DPOSIX -DLINUX -DAME_FILE=\"/home/lyubenk/Downloads/MiniballSort/data/mass_1.mas20\" -DSRIM_DIR=\"/home/lyubenk/Downloads/MiniballSort/srim/\" -DCUR_DIR=\"/home/lyubenk/Downloads/MiniballSort/\" -DROOTVER=6 -DROOTSUBVER=12/06 -I./include -I. mb_sort.cc mb_sort.hh

In file included from ./include/MiniballGUI.hh:37:0, from mb_sort.cc:6: ./include/Calibration.hh: In member function ‘TGraph* FebexMWD::GetGraph(std::vector&)’: ./include/Calibration.hh:119:31: error: ‘make_unique’ is not a member of ‘std’ std::unique_ptr g = std::make_unique(

./include/Calibration.hh:119:54: error: expected primary-expression before ‘>’ token std::unique_ptr g = std::make_unique(

In file included from ./include/Converter.hh:34:0, from ./include/MidasConverter.hh:6, from ./include/MiniballGUI.hh:47, from mb_sort.cc:6: ./include/DataPackets.hh: In member function ‘TGraph* DgfData::GetTraceGraph()’: ./include/DataPackets.hh:241:31: error: ‘make_unique’ is not a member of ‘std’ std::unique_ptr g = std::make_unique(

mb_sort.cc: In function ‘void start_http()’: mb_sort.cc:376:9: error: ‘make_unique’ is not a member of ‘std’ serv = std::make_unique( server_name.data() );

mb_sort.cc: In function ‘int main(int, char**)’: mb_sort.cc:752:52: error: ‘make_unique’ is not a member of ‘std’ std::unique_ptr interface = std::make_unique();`

A possible fix is to include ROOT/RMakeUnique.hxx for older versions.

lpgaff commented 2 months ago

Can you please report the output of:

$(bash root-config --cxx) --version

The minimum C++ standard is C++14 at the moment, but I can see that you have the compiler flag --c++11 in the make command. This comes from the ROOT configuration at build. I can add the header file from ROOT to fix this issue, but I cannot guarantee yet that everything else will work. Maybe you can test locally and report back?

I cannot apply this fix yet, because this header file is not available in ROOT installs that are built with C++14, I think. Therefore it would break things unless I do some strict version checking, which I want to avoid if there are multiple other issues to be resolved with the C++11 standard.

Of course, my suggested fix would be to recompile ROOT with C++14, but people generally want to avoid reinstalling ROOT :-)

lyubenkod commented 2 months ago

c++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

To be fair we're running on quite an old system therefore I can't build it with C++14, so it's OK if you do not add compatibility for older versions as the code gets quite cluttered.

Just wanted to share that there are some compatibility issues with older ROOT versions.

lyubenkod commented 2 months ago

Another issue I've found is that there is no AddPoint method for the TGraph class, as it wasn't added until ROOT version 6.24. I've swapped with with tgraph->SetPoint(tgraph->GetN(), x,y) in my local version.

lpgaff commented 2 months ago

c++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I think full support for C++14 came in gcc 4.9 and later. I will add in the README that ROOT must be built with C++14 support.

Another issue I've found is that there is no AddPoint method for the TGraph class, as it wasn't added until ROOT version 6.24. I've swapped with with tgraph->SetPoint(tgraph->GetN(), x,y) in my local version.

We can also easily change the AddPoint method in the main branch. If you have those changes, feel free to commit them as a pull request and I wil merge. That doesn't need C++14, and there is no downside to having compatibility for older versions here.