Warning will be initialized after [-Wreorder]

That is warning. But I didn’t see the warnings in the original sample. But I have those warnings.
How can I clear the Warnings?

My class has

class PlateRecognition
{
  public:
    explicit PlateRecognition(const samplesCommon::OnnxSampleParams& params) : mParams(params) , mEngine(nullptr){}


  private:
    std::shared_ptr<nvinfer1::ICudaEngine> mEngine;
    samplesCommon::OnnxSampleParams mParams;
    nvinfer1::Dims mInputDims;  
    nvinfer1::Dims mOutputDims; 

};

The warnings are

NumPlateRecognition.cpp: In constructor ‘PlateRecognition::PlateRecognition(const samplesCommon::OnnxSampleParams&)’:
NumPlateRecognition.cpp:324:37: warning: ‘PlateRecognition::mParams’ will be initialized after [-Wreorder]
     samplesCommon::OnnxSampleParams mParams;
                                     ^~~~~~~
NumPlateRecognition.cpp:323:44: warning:   ‘std::shared_ptr<nvinfer1::ICudaEngine> PlateRecognition::mEngine’ [-Wreorder]
     std::shared_ptr<nvinfer1::ICudaEngine> mEngine;
                                            ^~~~~~~
NumPlateRecognition.cpp:179:14: warning:   when initialized here [-Wreorder]
     explicit PlateRecognition(const samplesCommon::OnnxSampleParams& params) : mParams(params) , mEngine(nullptr){}
              ^~~~~~~~~~~~~~~~

How can I clear warnings?

Hi @edit_or,
The errors you are getting are compile time issues to which you may get the answers from the below link.

Thanks!

Good thanks. I need to change the order of initialization.

1 Like