Skip to content

Commit

Permalink
Fix GCC 7 errors (inc. buffer size and fix TString conversion)
Browse files Browse the repository at this point in the history
TString supports conversions to std::string and std::string_view in
C++17 which causes ambiguity as std::string ctors and operators support
both also. Compiler cannot decide which one to use. We have either call
explicitly conversion operatator on TString (e.g., via static_cast) or
use other methods (e.g. construct std::string from const char *
TString::Data()).

In some cases compiler says that buffers are too small.

TStrings could also be removed and replaced with C++ standard functions.

Signed-off-by: David Abdurachmanov <David.Abdurachmanov@cern.ch>
  • Loading branch information
David Abdurachmanov authored and David Abdurachmanov committed Feb 7, 2017
1 parent 4e8bdca commit bbebe5a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions Alignment/CocoaModel/src/CocoaDaqReaderRoot.cc
Expand Up @@ -8,6 +8,7 @@
#include "CondFormats/OptAlignObjects/interface/OpticalAlignMeasurements.h"

#include <iostream>
#include <string>

#include "TClonesArray.h"

Expand Down Expand Up @@ -128,7 +129,7 @@ OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromPosition2D( AliDaqPos
OpticalAlignMeasurementInfo meas;

meas.type_ = "SENSOR2D";
meas.name_ = pos2D->GetID();
meas.name_ = std::string(pos2D->GetID().Data());
//- std::vector<std::string> measObjectNames_;
std::vector<bool> isSimu;
for( size_t jj = 0; jj < 2; jj++ ){
Expand Down Expand Up @@ -160,7 +161,7 @@ OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromPositionCOPS( AliDaqP
OpticalAlignMeasurementInfo meas;

meas.type_ = "COPS";
meas.name_ = posCOPS->GetID();
meas.name_ = std::string(posCOPS->GetID().Data());
//- std::vector<std::string> measObjectNames_;
std::vector<bool> isSimu;
for( size_t jj = 0; jj < 4; jj++ ){
Expand Down Expand Up @@ -205,7 +206,7 @@ OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromTilt( AliDaqTilt* til
OpticalAlignMeasurementInfo meas;

meas.type_ = "TILTMETER";
meas.name_ = tilt->GetID();
meas.name_ = std::string(tilt->GetID().Data());
//- std::vector<std::string> measObjectNames_;
std::vector<bool> isSimu;
for( size_t jj = 0; jj < 2; jj++ ){
Expand All @@ -232,7 +233,7 @@ OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromDist( AliDaqDistance*
OpticalAlignMeasurementInfo meas;

meas.type_ = "DISTANCEMETER";
meas.name_ = dist->GetID();
meas.name_ = std::string(dist->GetID().Data());
//- std::vector<std::string> measObjectNames_;
std::vector<bool> isSimu;
for( size_t jj = 0; jj < 2; jj++ ){
Expand Down
Expand Up @@ -55,7 +55,7 @@ void AlignmentMonitorGeneric::book()
alignableObjectId.idToString(type),
id, DetId(id).subdetId());

hists[n] = book1D(std::string("/iterN/") + std::string(name) + std::string("/"), std::string(histName), std::string(histTitle), nBin_, -5., 5.);
hists[n] = book1D(std::string("/iterN/") + std::string(name) + std::string("/"), std::string(histName.Data()), std::string(histTitle.Data()), nBin_, -5., 5.);
}
}

Expand Down
Expand Up @@ -1090,7 +1090,7 @@ HIPAlignmentAlgorithm::calcAPE(double* par, int iter, double function)
void HIPAlignmentAlgorithm::bookRoot(void)
{
TString tname="T1";
char iterString[5];
char iterString[15];
snprintf(iterString, sizeof(iterString), "%i",theIteration);
tname.Append("_");
tname.Append(iterString);
Expand Down
Expand Up @@ -837,7 +837,7 @@ void MuonAlignmentAnalyzer::endJob(){



char binLabel[15];
char binLabel[40];

for(unsigned int i=0 ; i<unitsLocalX.size() ; i++)
{
Expand Down

0 comments on commit bbebe5a

Please sign in to comment.