Skip to content

Commit

Permalink
sns: static constexpr inline variables
Browse files Browse the repository at this point in the history
amend 49cd7fc
feature flag dependency instead of minimal std version

also see #2624
  • Loading branch information
mcspr committed Nov 5, 2024
1 parent dc9ba63 commit 0976bdb
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion code/espurna/sensors/ADE7953Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ class ADE7953Sensor : public BaseEmonSensor {
Reading _last_reading;
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude ADE7953Sensor::Magnitudes[];
#endif

Expand Down
9 changes: 8 additions & 1 deletion code/espurna/sensors/AnalogSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,15 @@ class AnalogSensor : public BaseAnalogSensor {
double _offset { 0.0 };
};

constexpr double AnalogSensor::RawMin;
#ifndef __cpp_inline_variables
constexpr int AnalogSensor::RawBits;

constexpr double AnalogSensor::RawMax;
constexpr double AnalogSensor::RawMin;

constexpr size_t AnalogSensor::SamplesMin;
constexpr size_t AnalogSensor::SamplesMax;

constexpr AnalogSensor::Delay AnalogSensor::DelayMin;
constexpr AnalogSensor::Delay AnalogSensor::DelayMax;
#endif
2 changes: 1 addition & 1 deletion code/espurna/sensors/BME680Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class BME680Sensor : public I2CSensor<> {

};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude BME680Sensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/BMX280Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ class BMX280Sensor : public I2CSensor<> {

};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude BMX280Sensor::Bmp280Magnitudes[];
constexpr BaseSensor::Magnitude BMX280Sensor::Bme280Magnitudes[];
constexpr espurna::duration::Milliseconds BMX280Sensor::StatusDelay;
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/BaseAnalogEmonSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class BaseAnalogEmonSensor : public BaseEmonSensor {
size_t _adc_counts { static_cast<size_t>(1) << _resolution }; // Max count
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude BaseAnalogEmonSensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/CSE7766Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class CSE7766Sensor : public BaseEmonSensor {

};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude CSE7766Sensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/DummySensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct Sensor : public BaseEmonSensor {
double _delta { 0.0 };
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude Sensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/ECH1560Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class ECH1560Sensor : public BaseEmonSensor {
unsigned char _data[24] {0};
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseEmonSensor::Magnitude ECH1560Sensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/GeigerSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ TimeSource::time_point _lastreport_sv = _lastreport_cpm;

};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude GeigerSensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/HLW8012Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class HLW8012Sensor : public BaseEmonSensor {
HLW8012 _hlw8012{};
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseEmonSensor::Magnitude HLW8012Sensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/INA219Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ class INA219Sensor : public I2CSensor<BaseEmonSensor> {
}
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude INA219Sensor::Magnitudes[];
constexpr BaseSensor::Magnitude INA219Sensor::RatioSupport[];
#endif
2 changes: 1 addition & 1 deletion code/espurna/sensors/PMSX003Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class PMSX003Sensor : public BaseSensor, PMSX003 {

};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr PMSX003Sensor::Spec PMSX003Sensor::Specs[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/PZEM004TSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ class PZEM004TSensor : public BaseEmonSensor {
Reading _reading;
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseEmonSensor::Magnitude PZEM004TSensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/PZEM004TV30Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ class PZEM004TV30Sensor : public BaseEmonSensor {
static Instance _instance;
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseEmonSensor::Magnitude PZEM004TV30Sensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/PulseMeterSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class PulseMeterSensor : public BaseEmonSensor {
int _interrupt_mode = FALLING;
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude PulseMeterSensor::Magnitudes[];
#endif

Expand Down
2 changes: 1 addition & 1 deletion code/espurna/sensors/V9261FSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class V9261FSensor : public BaseEmonSensor {
Stream* _serial { nullptr };
};

#if __cplusplus < 201703L
#ifndef __cpp_inline_variables
constexpr BaseSensor::Magnitude V9261FSensor::Magnitudes[];
#endif

Expand Down

0 comments on commit 0976bdb

Please sign in to comment.