JoeStrout/miniscript

[C++] Fix "reorder" warnings (make constructor initializers match member order)

Opened this issue · 0 comments

If you compile the MiniScript source code using a compiler that supports the "reorder" warning (-Wreorder), such as gcc/g++, then this warning crops up in quite a few places. For example:

MiniScript/MiniscriptInterpreter.h:155:25: warning: 'MiniScript::Interpreter::parser' will be initialized after [-Wreorder]
  155 |                 Parser *parser;
      |                         ^~~~~~
MiniScript/MiniscriptInterpreter.h:45:26: warning:   'MiniScript::Machine* MiniScript::Interpreter::vm' [-Wreorder]
   45 |                 Machine *vm;
      |                          ^~
MiniScript/MiniscriptInterpreter.cpp:15:9: warning:   when initialized here [-Wreorder]
   15 |         Interpreter::Interpreter() : standardOutput(nullptr), errorOutput(nullptr), implicitOutput(nullptr),
      |         ^~~~~~~~~~~

I don't think there's anywhere that this really matters, but in order to compile cleanly, it'd be a good idea to make these orders match (reasons why are explained at [https://stackoverflow.com/questions/1828037]).

So, get yourself set up with such an environment, and fix all the "reorder" warnings by either changing the order of declarations in the header to match the constructor, or changing the order of initializers in the constructor to match the declarations.