The lack of formal C++ training hits me, I am failing to express myself so that my compiler is happy
I want trigger_shape_s to initialize an array of two single_wave_s references and pass that array to a constructor of a member wave.
I am trying
class trigger_shape_s {
public:
trigger_shape_s();
multi_wave_s wave;
private:
single_wave_s waves[2];
single_wave_s sr[2] = {waves[0], waves[1]};
};
trigger_shape_s::trigger_shape_s() :
wave(sr) {
}
class multi_wave_s {
public:
multi_wave_s(single_wave_s *waves);
}
With a GCC 4.8.1 on Windows I've got a warning suggesting I use -std=c++11. Fine, I did that and the code compiles on Windows.
The funny thing is that my Unix 4.8.3 build server which uses the same exact Makefile is not happy:
./firmware/controllers/trigger/trigger_structure.h:96:24: error: a brace-enclosed initializer is not allowed here before '{' token
../firmware/controllers/trigger/trigger_structure.h:96:43: warning: ISO C++ forbids initialization of member 'sr' [-fpermissive]
../firmware/controllers/trigger/trigger_structure.h:96:43: warning: making 'sr' static [-fpermissive]
../firmware/controllers/trigger/trigger_structure.h:96:43: error: invalid in-class initialization of static data member of non-integral type 'single_wave_s [2]'
Just to be sure - as far as I understand 'static' attribute I do NOT want any members here to be static - I want each instance of trigger_shape_s to hold it's own array.
Please advice - how do I properly implement the thing I am trying to implement?
I want trigger_shape_s to initialize an array of two single_wave_s references and pass that array to a constructor of a member wave.
I am trying
class trigger_shape_s {
public:
trigger_shape_s();
multi_wave_s wave;
private:
single_wave_s waves[2];
single_wave_s sr[2] = {waves[0], waves[1]};
};
trigger_shape_s::trigger_shape_s() :
wave(sr) {
}
class multi_wave_s {
public:
multi_wave_s(single_wave_s *waves);
}
With a GCC 4.8.1 on Windows I've got a warning suggesting I use -std=c++11. Fine, I did that and the code compiles on Windows.
The funny thing is that my Unix 4.8.3 build server which uses the same exact Makefile is not happy:
./firmware/controllers/trigger/trigger_structure.h:96:24: error: a brace-enclosed initializer is not allowed here before '{' token
../firmware/controllers/trigger/trigger_structure.h:96:43: warning: ISO C++ forbids initialization of member 'sr' [-fpermissive]
../firmware/controllers/trigger/trigger_structure.h:96:43: warning: making 'sr' static [-fpermissive]
../firmware/controllers/trigger/trigger_structure.h:96:43: error: invalid in-class initialization of static data member of non-integral type 'single_wave_s [2]'
Just to be sure - as far as I understand 'static' attribute I do NOT want any members here to be static - I want each instance of trigger_shape_s to hold it's own array.
Please advice - how do I properly implement the thing I am trying to implement?