diff --git a/Subsurface-mobile.pro b/Subsurface-mobile.pro index d4edc909d..ec4f1bd7f 100644 --- a/Subsurface-mobile.pro +++ b/Subsurface-mobile.pro @@ -66,7 +66,7 @@ SOURCES += subsurface-mobile-main.cpp \ core/parse.c \ core/picture.c \ core/pictureobj.cpp \ - core/sample.c \ + core/sample.cpp \ core/import-suunto.c \ core/import-shearwater.c \ core/import-seac.c \ diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index d6635e38b..2814bb7df 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -153,7 +153,7 @@ set(SUBSURFACE_CORE_LIB_SRCS qthelper.cpp qthelper.h range.h - sample.c + sample.cpp sample.h save-git.c save-html.c diff --git a/core/dive.cpp b/core/dive.cpp index b14c89594..f3040131b 100644 --- a/core/dive.cpp +++ b/core/dive.cpp @@ -1337,7 +1337,7 @@ static void merge_one_sample(const struct sample *sample, int time, struct divec * a minute apart, and shallower than 5m */ if (time > last_time + 60 && last_depth < 5000) { - struct sample surface = { 0 }; + struct sample surface; /* Init a few values from prev sample to avoid useless info in XML */ surface.bearing.degrees = prev->bearing.degrees; @@ -1388,7 +1388,7 @@ static void merge_samples(struct divecomputer *res, for (;;) { int j; int at, bt; - struct sample sample = { .ndl{ -1 } , .bearing{ -1 } }; + struct sample sample; if (!res) return; diff --git a/core/sample.c b/core/sample.cpp similarity index 72% rename from core/sample.c rename to core/sample.cpp index fd68a4aa7..ff2cbfa67 100644 --- a/core/sample.c +++ b/core/sample.cpp @@ -2,6 +2,28 @@ #include "sample.h" +sample::sample() : + time({ 0 }), + stoptime({ 0 }), + ndl({ -1 }), + tts({ 0 }), + rbt({ 0 }), + depth({ 0 }), + stopdepth({ 0 }), + temperature({ 0 }), + pressure { { 0 }, { 0 } }, + setpoint({ 0 }), + o2sensor { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 } }, + bearing({ -1 }), + sensor { 0, 0 }, + cns(0), + heartbeat(0), + sac({ 0 }), + in_deco(false), + manually_entered(false) +{ +} + /* * Adding a cylinder pressure sample field is not quite as trivial as it * perhaps should be. @@ -15,7 +37,7 @@ * from the previous sample, so the indices are pre-populated (but the * pressures obviously are not) */ -void add_sample_pressure(struct sample *sample, int sensor, int mbar) +extern "C" void add_sample_pressure(struct sample *sample, int sensor, int mbar) { int idx; @@ -42,4 +64,3 @@ void add_sample_pressure(struct sample *sample, int sensor, int mbar) /* We do not have enough slots for the pressure samples. */ /* Should we warn the user about dropping pressure data? */ } - diff --git a/core/sample.h b/core/sample.h index 4710162e0..7e3655d98 100644 --- a/core/sample.h +++ b/core/sample.h @@ -33,6 +33,9 @@ struct sample // BASE TYPE BYTES UNITS RANGE bool in_deco; // bool 1 y/n y/n this sample is part of deco bool manually_entered; // bool 1 y/n y/n this sample was entered by the user, // not calculated when planning a dive +#ifdef __cplusplus + sample(); // Default constructor +#endif }; // Total size of structure: 63 bytes, excluding padding at end extern void add_sample_pressure(struct sample *sample, int sensor, int mbar);