From 03b910ee7fb2b68d90e37d93c51c4cede9cdf9f5 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 4 May 2024 17:55:50 +0200 Subject: [PATCH] core: remove __cplusplus ifdefs Since all source files are now C++, this is redundant. Signed-off-by: Berthold Stoeger --- core/deco.h | 9 +-------- core/device.h | 12 ++---------- core/dive.h | 12 +----------- core/divecomputer.h | 4 ---- core/divelist.h | 4 ---- core/divelog.h | 6 ------ core/divesite.h | 3 --- core/equipment.h | 13 ++++--------- core/errorhelper.h | 5 ----- core/event.h | 4 ---- core/eventtype.h | 12 +++--------- core/file.h | 13 ++----------- core/filterconstraint.h | 14 +------------- core/filterpreset.h | 30 +++++------------------------- core/format.h | 2 -- core/fulltext.h | 7 +------ core/gas.h | 8 -------- core/gaspressures.h | 3 --- core/gettext.h | 12 ------------ core/git-access.h | 17 ++++------------- core/import-csv.h | 4 ---- core/libdivecomputer.h | 5 +---- core/membuffer.h | 5 ----- core/metadata.h | 4 ---- core/namecmp.h | 3 --- core/parse.h | 8 +------- core/picture.h | 4 ---- core/planner.h | 6 +----- core/pref.h | 6 ------ core/profile.h | 3 --- core/qt-ble.h | 1 - core/qthelper.h | 8 -------- core/sample.h | 6 ------ core/save-html.h | 4 ---- core/save-profiledata.h | 4 ---- core/selection.h | 7 ------- core/sha1.h | 4 ---- core/ssrf.h | 5 ----- core/statistics.h | 4 ---- core/subsurface-float.h | 7 ------- core/subsurface-string.h | 12 +++--------- core/subsurface-time.h | 7 +------ core/subsurfacestartup.h | 7 ------- core/subsurfacesysinfo.h | 2 -- core/tag.h | 10 ---------- core/taxonomy.h | 3 --- core/trip.h | 5 ----- core/uemis.h | 4 ---- core/units.h | 14 -------------- core/uploadDiveLogsDE.h | 2 +- core/uploadDiveShare.h | 2 +- core/version.h | 4 ---- core/webservice.h | 4 ---- core/worldmap-save.h | 4 ---- core/xmlparams.h | 16 ++++------------ 55 files changed, 37 insertions(+), 347 deletions(-) diff --git a/core/deco.h b/core/deco.h index f550aefe3..5d2dbba06 100644 --- a/core/deco.h +++ b/core/deco.h @@ -5,10 +5,9 @@ #include "units.h" #include "gas.h" #include "divemode.h" +#include -#ifdef __cplusplus extern "C" { -#endif struct dive; struct divecomputer; @@ -70,12 +69,8 @@ extern double regressionb(const struct deco_state *ds); extern void reset_regression(struct deco_state *ds); extern void update_regression(struct deco_state *ds, const struct dive *dive); -#ifdef __cplusplus } -// C++ only functions - -#include struct deco_state_cache { // Test if there is cached data operator bool () { @@ -87,6 +82,4 @@ private: std::unique_ptr data; }; -#endif - #endif // DECO_H diff --git a/core/device.h b/core/device.h index 147f56e1e..1d9b4210e 100644 --- a/core/device.h +++ b/core/device.h @@ -3,10 +3,10 @@ #define DEVICE_H #include +#include +#include -#ifdef __cplusplus extern "C" { -#endif struct divecomputer; struct device; @@ -61,15 +61,9 @@ typedef void (*device_callback_t)(const char *name, void *userdata); extern int enumerate_devices(device_callback_t callback, void *userdata, unsigned int transport); -#ifdef __cplusplus } -#endif // Functions and global variables that are only available to C++ code -#ifdef __cplusplus - -#include -#include struct device { bool operator<(const device &a) const; void showchanges(const std::string &n) const; @@ -101,6 +95,4 @@ struct fingerprint_table { std::string fp_get_data(struct fingerprint_table *table, unsigned int i); -#endif - #endif // DEVICE_H diff --git a/core/dive.h b/core/dive.h index 9029f7442..e78214282 100644 --- a/core/dive.h +++ b/core/dive.h @@ -11,11 +11,9 @@ #include #include - -#ifdef __cplusplus #include + extern "C" { -#endif extern int last_xml_version; @@ -115,12 +113,8 @@ extern depth_t gas_mnd(struct gasmix mix, depth_t end, const struct dive *dive, extern struct dive *get_dive(int nr); extern struct dive *get_dive_from_table(int nr, const struct dive_table *dt); extern struct dive_site *get_dive_site_for_dive(const struct dive *dive); -#ifdef __cplusplus -} // TODO: remove extern std::string get_dive_country(const struct dive *dive); extern std::string get_dive_location(const struct dive *dive); -extern "C" { -#endif extern unsigned int number_of_computers(const struct dive *dive); extern struct divecomputer *get_dive_dc(struct dive *dive, int nr); extern const struct divecomputer *get_dive_dc_const(const struct dive *dive, int nr); @@ -224,8 +218,6 @@ extern struct gasmix get_gasmix(const struct dive *dive, const struct divecomput extern struct gasmix get_gasmix_at_time(const struct dive *dive, const struct divecomputer *dc, duration_t time); extern void update_setpoint_events(const struct dive *dive, struct divecomputer *dc); - -#ifdef __cplusplus } /* Make pointers to dive and dive_trip "Qt metatypes" so that they can be passed through @@ -236,6 +228,4 @@ Q_DECLARE_METATYPE(struct dive *); extern std::string existing_filename; -#endif - #endif // DIVE_H diff --git a/core/divecomputer.h b/core/divecomputer.h index a20cd967c..d4d0f834a 100644 --- a/core/divecomputer.h +++ b/core/divecomputer.h @@ -5,9 +5,7 @@ #include "divemode.h" #include "units.h" -#ifdef __cplusplus extern "C" { -#endif struct extra_data; struct sample; @@ -77,8 +75,6 @@ extern void make_manually_added_dive_dc(struct divecomputer *dc); /* Check if two dive computer entries are the exact same dive (-1=no/0=maybe/1=yes) */ extern int match_one_dc(const struct divecomputer *a, const struct divecomputer *b); -#ifdef __cplusplus } -#endif #endif diff --git a/core/divelist.h b/core/divelist.h index fae9a5d36..c46316bf2 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -4,9 +4,7 @@ #include "units.h" -#ifdef __cplusplus extern "C" { -#endif struct dive; struct divelog; @@ -62,8 +60,6 @@ void move_dive_table(struct dive_table *src, struct dive_table *dst); struct dive *unregister_dive(int idx); extern bool has_dive(unsigned int deviceid, unsigned int diveid); -#ifdef __cplusplus } -#endif #endif // DIVELIST_H diff --git a/core/divelog.h b/core/divelog.h index e1eb01770..44ec950a4 100644 --- a/core/divelog.h +++ b/core/divelog.h @@ -18,26 +18,20 @@ struct divelog { struct device_table *devices; struct filter_preset_table *filter_presets; bool autogroup; -#ifdef __cplusplus void clear(); divelog(); ~divelog(); divelog(divelog &&log); // move constructor (argument is consumed). divelog &operator=(divelog &&log); // move assignment (argument is consumed). -#endif }; extern struct divelog divelog; -#ifdef __cplusplus extern "C" { -#endif void clear_divelog(struct divelog *); extern void delete_single_dive(struct divelog *, int idx); -#ifdef __cplusplus } -#endif #endif diff --git a/core/divesite.h b/core/divesite.h index dd10819ce..2d199fbb7 100644 --- a/core/divesite.h +++ b/core/divesite.h @@ -7,7 +7,6 @@ #include "divelist.h" #include -#ifdef __cplusplus #include struct dive_site @@ -75,6 +74,4 @@ std::string constructLocationTags(const taxonomy_data &taxonomy, bool for_mainta /* Make pointer-to-dive_site a "Qt metatype" so that we can pass it through QVariants */ Q_DECLARE_METATYPE(dive_site *); -#endif - #endif // DIVESITE_H diff --git a/core/equipment.h b/core/equipment.h index 30c47ab5b..a048b49bf 100644 --- a/core/equipment.h +++ b/core/equipment.h @@ -4,9 +4,11 @@ #include "gas.h" -#ifdef __cplusplus +#include +#include +#include + extern "C" { -#endif struct dive; @@ -107,13 +109,8 @@ extern void add_cylinder(struct cylinder_table *, int idx, cylinder_t cyl); void get_gas_string(struct gasmix gasmix, char *text, int len); const char *gasname(struct gasmix gasmix); -#ifdef __cplusplus } -#include -#include -#include - struct ws_info { std::string name; weight_t weight; @@ -135,6 +132,4 @@ extern std::pair get_tank_info_data(const std::vector &table); -#endif - #endif // EQUIPMENT_H diff --git a/core/errorhelper.h b/core/errorhelper.h index d81ea8a96..f90927d8e 100644 --- a/core/errorhelper.h +++ b/core/errorhelper.h @@ -4,9 +4,7 @@ // error reporting functions -#ifdef __cplusplus extern "C" { -#endif #ifdef __GNUC__ #define __printf(x, y) __attribute__((__format__(__printf__, x, y))) @@ -19,9 +17,6 @@ extern int __printf(1, 2) report_error(const char *fmt, ...); extern void __printf(1, 2) report_info(const char *fmt, ...); extern void set_error_cb(void(*cb)(char *)); // Callback takes ownership of passed string - -#ifdef __cplusplus } -#endif #endif diff --git a/core/event.h b/core/event.h index fc8a03d64..413da7248 100644 --- a/core/event.h +++ b/core/event.h @@ -8,9 +8,7 @@ #include -#ifdef __cplusplus extern "C" { -#endif enum event_severity { EVENT_SEVERITY_NONE = 0, @@ -60,8 +58,6 @@ extern enum event_severity get_event_severity(const struct event *ev); extern const struct event *get_next_event(const struct event *event, const char *name); extern struct event *get_next_event_mutable(struct event *event, const char *name); -#ifdef __cplusplus } -#endif #endif diff --git a/core/eventtype.h b/core/eventtype.h index 8f5a8f5ac..37a589424 100644 --- a/core/eventtype.h +++ b/core/eventtype.h @@ -3,9 +3,10 @@ #ifndef EVENTNAME_H #define EVENTNAME_H -#ifdef __cplusplus +#include +#include + extern "C" { -#endif extern void clear_event_types(void); extern void remember_event_type(const struct event *ev); @@ -15,17 +16,10 @@ extern void show_all_event_types(); extern void show_event_type(int idx); extern bool any_event_types_hidden(); -#ifdef __cplusplus } -// C++-only functions - -#include -#include extern std::vector hidden_event_types(); QString event_type_name(const event *ev); QString event_type_name(int idx); #endif - -#endif diff --git a/core/file.h b/core/file.h index 3303f224f..3f93a2f72 100644 --- a/core/file.h +++ b/core/file.h @@ -6,13 +6,13 @@ #include #include +#include +#include struct divelog; struct zip; -#ifdef __cplusplus extern "C" { -#endif extern void ostctools_import(const char *file, struct divelog *log); extern int parse_file(const char *filename, struct divelog *log); @@ -29,21 +29,12 @@ extern int subsurface_stat(const char *path, struct stat *buf); extern struct zip *subsurface_zip_open_readonly(const char *path, int flags, int *errorp); extern int subsurface_zip_close(struct zip *zip); -#ifdef __cplusplus - } -// C++ only functions - -#include -#include - // return data, errorcode pair. extern std::pair readfile(const char *filename); extern int try_to_open_cochran(const char *filename, std::string &mem, struct divelog *log); extern int try_to_open_liquivision(const char *filename, std::string &mem, struct divelog *log); extern int datatrak_import(std::string &mem, std::string &wl_mem, struct divelog *log); -#endif - #endif // FILE_H diff --git a/core/filterconstraint.h b/core/filterconstraint.h index b906a8e03..684c30448 100644 --- a/core/filterconstraint.h +++ b/core/filterconstraint.h @@ -5,15 +5,11 @@ #define FILTER_CONSTRAINT_H #include "units.h" +#include struct dive; -#ifdef __cplusplus -#include extern "C" { -#else -typedef void QStringList; -#endif enum filter_constraint_type { FILTER_CONSTRAINT_DATE, @@ -82,7 +78,6 @@ struct filter_constraint { QStringList *string_list; uint64_t multiple_choice; // bit-field for multiple choice lists. currently, we support 64 items, extend if needed. } data; -#ifdef __cplusplus // For C++, define constructors, assignment operators and destructor to make our lives easier. filter_constraint(filter_constraint_type type); filter_constraint(const char *type, const char *string_mode, @@ -91,7 +86,6 @@ struct filter_constraint { filter_constraint &operator=(const filter_constraint &); ~filter_constraint(); bool operator==(const filter_constraint &f2) const; -#endif }; extern const char *filter_constraint_type_to_string(enum filter_constraint_type); @@ -117,12 +111,8 @@ extern bool filter_constraint_has_time_widget(enum filter_constraint_type); extern int filter_constraint_num_decimals(enum filter_constraint_type); extern bool filter_constraint_is_valid(const struct filter_constraint *constraint); -#ifdef __cplusplus } -#endif -// C++ only functions -#ifdef __cplusplus QString filter_constraint_type_to_string_translated(enum filter_constraint_type); QString filter_constraint_negate_to_string_translated(bool negate); QString filter_constraint_string_mode_to_string_translated(enum filter_constraint_string_mode); @@ -154,5 +144,3 @@ bool filter_constraint_match_dive(const filter_constraint &c, const struct dive std::string filter_constraint_data_to_string(const struct filter_constraint *constraint); // caller takes ownership of returned string #endif - -#endif diff --git a/core/filterpreset.h b/core/filterpreset.h index c15a88fdf..40037a948 100644 --- a/core/filterpreset.h +++ b/core/filterpreset.h @@ -8,17 +8,14 @@ #ifndef FILTER_PRESETS_H #define FILTER_PRESETS_H -struct dive; -struct filter_constraint; - -// So that we can pass filter preset table between C and C++ we define -// it as an opaque type in C. Thus we can easily create the table in C++ -// without having to do our own memory management and pass pointers to -// void through C. -#ifdef __cplusplus #include "divefilter.h" #include #include + +struct dive; +struct filter_constraint; +struct FilterData; + struct filter_preset { std::string name; FilterData data; @@ -32,15 +29,7 @@ struct filter_preset_table : public std::vector { }; -#else -struct filter_preset; -struct filter_preset_table; -#endif - - -#ifdef __cplusplus extern "C" { -#endif // The C IO code accesses the filter presets via integer indices. extern int filter_presets_count(void); @@ -53,14 +42,7 @@ extern void add_filter_preset_to_table(const struct filter_preset *preset, struc extern void filter_preset_add_constraint(struct filter_preset *preset, const char *type, const char *string_mode, const char *range_mode, bool negate, const char *data); // called by the parser, therefore data passed as strings. -#ifdef __cplusplus } -#endif - -// C++ only functions -#ifdef __cplusplus - -struct FilterData; int filter_preset_id(const std::string &s); // for now, we assume that names are unique. returns -1 if no preset with that name. void filter_preset_set(int preset, const FilterData &d); // this will override a preset if the name already exists. @@ -71,5 +53,3 @@ std::string filter_preset_name(int preset); // name of filter preset - caller mu std::string filter_preset_fulltext_query(int preset); // fulltext query of filter preset - caller must free the result. #endif - -#endif diff --git a/core/format.h b/core/format.h index 599911082..0a03eea96 100644 --- a/core/format.h +++ b/core/format.h @@ -7,12 +7,10 @@ #define __printf(x, y) #endif -#ifdef __cplusplus #include __printf(1, 2) QString qasprintf_loc(const char *cformat, ...); __printf(1, 0) QString vqasprintf_loc(const char *cformat, va_list ap); __printf(1, 2) std::string casprintf_loc(const char *cformat, ...); __printf(1, 2) std::string format_string_std(const char *fmt, ...); -#endif #endif diff --git a/core/fulltext.h b/core/fulltext.h index 2f1c63db1..688db63d1 100644 --- a/core/fulltext.h +++ b/core/fulltext.h @@ -9,15 +9,14 @@ // To make this accessible from C, this does manual memory management: // Every dive is associated with a cache of words. Thus, when deleting // a dive, a function freeing that data has to be called. +// TODO: remove this complexity. #ifndef FULLTEXT_H #define FULLTEXT_H // 1) The C-accessible interface -#ifdef __cplusplus extern "C" { -#endif struct full_text_cache; struct dive; @@ -26,12 +25,9 @@ void fulltext_unregister(struct dive *d); // Note: can be called repeatedly void fulltext_unregister_all(); // Unregisters all dives in the dive table void fulltext_populate(); // Registers all dives in the dive table -#ifdef __cplusplus } -#endif // 2) The C++-only interface -#ifdef __cplusplus #include #include @@ -63,4 +59,3 @@ FullTextResult fulltext_find_dives(const FullTextQuery &q, StringFilterMode); bool fulltext_dive_matches(const struct dive *d, const FullTextQuery &q, StringFilterMode); #endif -#endif diff --git a/core/gas.h b/core/gas.h index 51403935c..03a73f613 100644 --- a/core/gas.h +++ b/core/gas.h @@ -5,11 +5,7 @@ #include "divemode.h" #include "units.h" -#ifdef __cplusplus extern "C" { -#else -#include -#endif enum gas_component { N2, HE, O2 }; @@ -60,11 +56,9 @@ static inline int get_n2(struct gasmix mix) int pscr_o2(const double amb_pressure, struct gasmix mix); -#ifdef __cplusplus struct gas_pressures { double o2 = 0.0, n2 = 0.0, he = 0.0; }; -#endif extern void sanitize_gasmix(struct gasmix *mix); extern int gasmix_distance(struct gasmix a, struct gasmix b); @@ -77,8 +71,6 @@ extern enum gastype gasmix_to_type(struct gasmix mix); extern const char *gastype_name(enum gastype type); extern fraction_t make_fraction(int f); -#ifdef __cplusplus } -#endif #endif diff --git a/core/gaspressures.h b/core/gaspressures.h index cc839e6f8..d6755c625 100644 --- a/core/gaspressures.h +++ b/core/gaspressures.h @@ -2,9 +2,6 @@ #ifndef GASPRESSURES_H #define GASPRESSURES_H -#ifdef __cplusplus - void populate_pressure_information(const struct dive *, const struct divecomputer *, struct plot_info &, int); -#endif #endif // GASPRESSURES_H diff --git a/core/gettext.h b/core/gettext.h index 806154007..c7fe5a2ae 100644 --- a/core/gettext.h +++ b/core/gettext.h @@ -2,22 +2,10 @@ #ifndef MYGETTEXT_H #define MYGETTEXT_H -#ifdef __cplusplus - extern "C" const char *trGettext(const char *); static inline const char *translate(const char *, const char *arg) { return trGettext(arg); } -#else - -/* this is for the Qt based translations */ -extern const char *trGettext(const char *); -#define translate(_context, arg) trGettext(arg) -#define QT_TRANSLATE_NOOP(_context, arg) arg -#define QT_TRANSLATE_NOOP3(_context, arg, _comment) arg - -#endif - #endif // MYGETTEXT_H diff --git a/core/git-access.h b/core/git-access.h index 8dedebed5..c3e706509 100644 --- a/core/git-access.h +++ b/core/git-access.h @@ -4,14 +4,14 @@ #include "git2.h" #include "filterpreset.h" +#include struct dive_log; +struct git_oid; +struct git_repository; +struct divelog; -#ifdef __cplusplus extern "C" { -#else -#include -#endif #define CLOUD_HOST_US "ssrf-cloud-us.subsurface-divelog.org" // preferred (faster/bigger) server in the US #define CLOUD_HOST_U2 "ssrf-cloud-u2.subsurface-divelog.org" // secondary (older) server in the US @@ -30,15 +30,8 @@ void set_git_update_cb(int(*)(const char *)); int git_storage_update_progress(const char *text); int get_authorship(git_repository *repo, git_signature **authorp); -#ifdef __cplusplus } -#include - -struct git_oid; -struct git_repository; -struct divelog; - struct git_info { std::string url; std::string branch; @@ -63,6 +56,4 @@ extern int git_load_dives(struct git_info *, struct divelog *log); extern int do_git_save(struct git_info *, bool select_only, bool create_empty); extern int git_create_local_repo(const std::string &filename); -#endif #endif // GITACCESS_H - diff --git a/core/import-csv.h b/core/import-csv.h index b71ad2308..e3ff5f950 100644 --- a/core/import-csv.h +++ b/core/import-csv.h @@ -21,9 +21,7 @@ enum csv_format { #define MAXCOLDIGITS 10 -#ifdef __cplusplus extern "C" { -#endif int parse_csv_file(const char *filename, struct xml_params *params, const char *csvtemplate, struct divelog *log); int try_to_open_csv(std::string &mem, enum csv_format type, struct divelog *log); @@ -32,8 +30,6 @@ int parse_txt_file(const char *filename, const char *csv, struct divelog *log); int parse_seabear_log(const char *filename, struct divelog *log); int parse_manual_file(const char *filename, struct xml_params *params, struct divelog *log); -#ifdef __cplusplus } -#endif #endif // IMPORTCSV_H diff --git a/core/libdivecomputer.h b/core/libdivecomputer.h index 38b9019da..84aebdbab 100644 --- a/core/libdivecomputer.h +++ b/core/libdivecomputer.h @@ -4,6 +4,7 @@ #include #include +#include /* libdivecomputer */ @@ -20,9 +21,6 @@ #define dc_usb_storage_open(stream, context, devname) (DC_STATUS_UNSUPPORTED) #endif -#ifdef __cplusplus -#include - extern "C" { struct dive; @@ -76,6 +74,5 @@ extern std::string logfile_name; extern std::string dumpfile_name; } -#endif #endif // LIBDIVECOMPUTER_H diff --git a/core/membuffer.h b/core/membuffer.h index 042675c4a..450ac4811 100644 --- a/core/membuffer.h +++ b/core/membuffer.h @@ -46,8 +46,6 @@ struct membuffer { char *buffer; }; -#ifdef __cplusplus - // In C++ code use this - it automatically frees the buffer, when going out of scope. struct membufferpp : public membuffer { membufferpp(); @@ -55,7 +53,6 @@ struct membufferpp : public membuffer { }; extern "C" { -#endif #ifdef __GNUC__ #define __printf(x, y) __attribute__((__format__(__printf__, x, y))) @@ -116,8 +113,6 @@ extern void put_salinity(struct membuffer *, int, const char *, const char *); extern void put_degrees(struct membuffer *b, degrees_t value, const char *, const char *); extern void put_location(struct membuffer *b, const location_t *, const char *, const char *); -#ifdef __cplusplus } -#endif #endif diff --git a/core/metadata.h b/core/metadata.h index 253763ad8..537eccc79 100644 --- a/core/metadata.h +++ b/core/metadata.h @@ -17,15 +17,11 @@ enum mediatype_t { MEDIATYPE_STILL_LOADING, // Still processing in the background }; -#ifdef __cplusplus extern "C" { -#endif enum mediatype_t get_metadata(const char *filename, struct metadata *data); timestamp_t picture_get_timestamp(const char *filename); -#ifdef __cplusplus } -#endif #endif // METADATA_H diff --git a/core/namecmp.h b/core/namecmp.h index f0781bb50..773fe57b9 100644 --- a/core/namecmp.h +++ b/core/namecmp.h @@ -2,8 +2,6 @@ #ifndef NAMECMP_H #define NAMECMP_H -#ifdef __cplusplus - #include // this is annoying Qt5 / Qt6 incompatibility where we can't compare against string literals anymore @@ -12,5 +10,4 @@ static inline int nameCmp(QXmlStreamReader &r, const char * cs) return r.name().compare(QLatin1String(cs)); } -#endif #endif // NAMECMP_H diff --git a/core/parse.h b/core/parse.h index 7cc1385e9..aaef654d3 100644 --- a/core/parse.h +++ b/core/parse.h @@ -12,6 +12,7 @@ #include #include +#include #include struct xml_params; @@ -22,11 +23,8 @@ typedef union { char allocation[sizeof(struct event) + MAX_EVENT_NAME]; } event_allocation_t; -#ifdef __cplusplus - /* * Dive info as it is being built up.. - * C++-only so we can use std::string */ struct parser_settings { @@ -145,7 +143,6 @@ void utf8_string_std(const char *buffer, std::string *res); void add_dive_site(const char *ds_name, struct dive *dive, struct parser_state *state); extern "C" { -#endif int trimspace(char *buffer); void start_match(const char *type, const char *name, char *buffer); @@ -164,10 +161,7 @@ int parse_shearwater_cloud_buffer(sqlite3 *handle, const char *url, const char * int parse_cobalt_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct divelog *log); int parse_divinglog_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct divelog *log); int parse_dlf_buffer(unsigned char *buffer, size_t size, struct divelog *log); -#ifdef __cplusplus } -#include std::string trimspace(const char *buffer); -#endif #endif diff --git a/core/picture.h b/core/picture.h index 39f526d3a..1f5b80e5e 100644 --- a/core/picture.h +++ b/core/picture.h @@ -6,9 +6,7 @@ #include "units.h" #include // For NULL -#ifdef __cplusplus extern "C" { -#endif struct dive; @@ -48,8 +46,6 @@ extern void sort_picture_table(struct picture_table *); extern struct picture *create_picture(const char *filename, timestamp_t shift_time, bool match_all, struct dive **dive); extern bool picture_check_valid_time(timestamp_t timestamp, timestamp_t shift_time); -#ifdef __cplusplus } -#endif #endif // PICTURE_H diff --git a/core/planner.h b/core/planner.h index dc145604d..fa285b7da 100644 --- a/core/planner.h +++ b/core/planner.h @@ -4,6 +4,7 @@ #include "units.h" #include "divemode.h" +#include /* this should be converted to use our types */ struct divedatapoint { @@ -33,9 +34,7 @@ struct diveplan { struct deco_state_cache; -#ifdef __cplusplus extern "C" { -#endif extern int validate_gas(const char *text, struct gasmix *gas); extern int validate_po2(const char *text, int *mbar_po2); @@ -55,11 +54,8 @@ struct decostop { int time; }; -#ifdef __cplusplus } -#include extern std::string get_planner_disclaimer_formatted(); extern bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, int dcNr, int timestep, struct decostop *decostoptable, deco_state_cache &cache, bool is_planner, bool show_disclaimer); -#endif #endif // PLANNER_H diff --git a/core/pref.h b/core/pref.h index ac9c5e0b3..456ca038e 100644 --- a/core/pref.h +++ b/core/pref.h @@ -5,11 +5,7 @@ #include "units.h" #include "taxonomy.h" -#ifdef __cplusplus extern "C" { -#else -#include -#endif typedef struct { @@ -228,8 +224,6 @@ extern void copy_prefs(struct preferences *src, struct preferences *dest); extern void set_informational_units(const char *units); -#ifdef __cplusplus } -#endif #endif // PREF_H diff --git a/core/profile.h b/core/profile.h index 378014250..a4a795143 100644 --- a/core/profile.h +++ b/core/profile.h @@ -2,8 +2,6 @@ #ifndef PROFILE_H #define PROFILE_H -#ifdef __cplusplus - #include "gas.h" // gas_pressures #include "sample.h" // MAX_O2_SENSORS @@ -150,5 +148,4 @@ static inline int get_plot_pressure(const struct plot_info &pi, int idx, int cyl std::pair> get_plot_details_new(const struct dive *d, const struct plot_info &pi, int time); std::vector compare_samples(const struct dive *d, const struct plot_info &pi, int idx1, int idx2, bool sum); -#endif #endif // PROFILE_H diff --git a/core/qt-ble.h b/core/qt-ble.h index e45f8de2e..0416a51a5 100644 --- a/core/qt-ble.h +++ b/core/qt-ble.h @@ -21,7 +21,6 @@ class BLEObject : public QObject { Q_OBJECT - public: BLEObject(QLowEnergyController *c, device_data_t &); ~BLEObject(); diff --git a/core/qthelper.h b/core/qthelper.h index 6bc89a11c..09bedabad 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -17,8 +17,6 @@ enum watertypes {FRESHWATER, BRACKISHWATER, EN13319WATER, SALTWATER, DC_WATERTYP // 2) Functions visible only to C++ parts -#ifdef __cplusplus - #include #include #include @@ -113,13 +111,9 @@ std::string move_away(const std::string &path); #define TITLE_OR_TEXT(_t, _m) _t, _m #endif -#endif - // 3) Functions visible to C and C++ -#ifdef __cplusplus extern "C" { -#endif struct git_info; @@ -143,8 +137,6 @@ volume_t string_to_volume(const char *str, pressure_t workp); fraction_t string_to_fraction(const char *str); void emit_reset_signal(); -#ifdef __cplusplus } -#endif #endif // QTHELPER_H diff --git a/core/sample.h b/core/sample.h index 7e3655d98..44e8c7c17 100644 --- a/core/sample.h +++ b/core/sample.h @@ -4,9 +4,7 @@ #include "units.h" -#ifdef __cplusplus extern "C" { -#endif #define MAX_SENSORS 2 #define MAX_O2_SENSORS 6 @@ -33,15 +31,11 @@ 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); -#ifdef __cplusplus } -#endif #endif diff --git a/core/save-html.h b/core/save-html.h index df3bb97af..af1c0ca76 100644 --- a/core/save-html.h +++ b/core/save-html.h @@ -4,9 +4,7 @@ #include "membuffer.h" -#ifdef __cplusplus extern "C" { -#endif struct dive; @@ -26,8 +24,6 @@ void export_list(struct membuffer *b, const char *photos_dir, bool selected_only void export_translation(const char *file_name); -#ifdef __cplusplus } -#endif #endif diff --git a/core/save-profiledata.h b/core/save-profiledata.h index 3720dc46c..9666b544f 100644 --- a/core/save-profiledata.h +++ b/core/save-profiledata.h @@ -2,14 +2,10 @@ #ifndef SAVE_PROFILE_DATA_H #define SAVE_PROFILE_DATA_H -#ifdef __cplusplus extern "C" { -#endif int save_profiledata(const char *filename, bool selected_only); void save_subtitles_buffer(struct membuffer *b, struct dive *dive, int offset, int length); -#ifdef __cplusplus } -#endif #endif // SAVE_PROFILE_DATA_H diff --git a/core/selection.h b/core/selection.h index 6c330f3bd..7175c9043 100644 --- a/core/selection.h +++ b/core/selection.h @@ -11,9 +11,7 @@ extern struct dive *current_dive; /*** C and C++ functions ***/ -#ifdef __cplusplus extern "C" { -#endif extern struct dive *first_selected_dive(void); extern struct dive *last_selected_dive(void); @@ -29,13 +27,10 @@ extern void clear_selection(void); extern void dump_selection(void); #endif -#ifdef __cplusplus } -#endif /*** C++-only functions ***/ -#ifdef __cplusplus #include #include @@ -64,6 +59,4 @@ std::vector getDiveSelection(); bool diveInSelection(const std::vector &selection, const dive *d); void updateSelection(std::vector &selection, const std::vector &add, const std::vector &remove); -#endif // __cplusplus - #endif // SELECTION_H diff --git a/core/sha1.h b/core/sha1.h index 4fbb4629a..f6411fd44 100644 --- a/core/sha1.h +++ b/core/sha1.h @@ -8,8 +8,6 @@ #ifndef SHA1_H #define SHA1_H -#ifdef __cplusplus - #include #include @@ -31,6 +29,4 @@ private: /* Helper function that calculates an SHA1 has and returns the first 4 bytes as uint32_t */ uint32_t SHA1_uint32(const void *dataIn, unsigned long len); -#endif - #endif // SHA1_H diff --git a/core/ssrf.h b/core/ssrf.h index 7f65f2dc5..78c4e951e 100644 --- a/core/ssrf.h +++ b/core/ssrf.h @@ -2,21 +2,16 @@ #ifndef SSRF_H #define SSRF_H -#ifdef __cplusplus extern "C" { -#endif #ifdef __clang__ // Clang has a bug on zero-initialization of C structs. #pragma clang diagnostic ignored "-Wmissing-field-initializers" #endif -#ifdef __cplusplus } -#else // Macro to be used for silencing unused parameters #define UNUSED(x) (void)x -#endif #endif // SSRF_H diff --git a/core/statistics.h b/core/statistics.h index afe7f6da7..b2971ac63 100644 --- a/core/statistics.h +++ b/core/statistics.h @@ -18,8 +18,6 @@ struct dive; -#ifdef __cplusplus - #include #include @@ -66,6 +64,4 @@ extern stats_t calculate_stats_selected(); extern std::vector get_gas_used(struct dive *dive); extern std::pair selected_dives_gas_parts(); // returns (O2, He) tuple -#endif - #endif // STATISTICS_H diff --git a/core/subsurface-float.h b/core/subsurface-float.h index 4dc225728..9f3b1eb27 100644 --- a/core/subsurface-float.h +++ b/core/subsurface-float.h @@ -4,10 +4,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - static inline bool nearly_equal(double a, double b) { return fabs(a - b) <= 1e-6 * fmax(fabs(a), fabs(b)); @@ -18,7 +14,4 @@ static inline bool nearly_0(double fp) return fabs(fp) <= 1e-6; } -#ifdef __cplusplus -} -#endif #endif // SUBSURFACE_FLOAT_H diff --git a/core/subsurface-string.h b/core/subsurface-string.h index 6598deaa9..61c70d71a 100644 --- a/core/subsurface-string.h +++ b/core/subsurface-string.h @@ -5,10 +5,11 @@ #include #include #include +#include +#include +#include -#ifdef __cplusplus extern "C" { -#endif // string handling @@ -35,13 +36,8 @@ static inline char *copy_string(const char *s) extern double permissive_strtod(const char *str, const char **ptr); extern double ascii_strtod(const char *str, const char **ptr); -#ifdef __cplusplus } -#include -#include -#include - // Sadly, starts_with only with C++20! inline bool starts_with(std::string_view s, const char *s2) { @@ -56,6 +52,4 @@ inline bool contains(std::string_view s, char c) std::string join(const std::vector &l, const std::string &separator, bool skip_empty = false); -#endif - #endif // SUBSURFACE_STRING_H diff --git a/core/subsurface-time.h b/core/subsurface-time.h index 10dc92e51..14a77bf20 100644 --- a/core/subsurface-time.h +++ b/core/subsurface-time.h @@ -3,11 +3,10 @@ #define TIME_H #include "units.h" +#include #include -#ifdef __cplusplus extern "C" { -#endif extern timestamp_t utc_mktime(const struct tm *tm); extern void utc_mkdate(timestamp_t, struct tm *tm); @@ -19,12 +18,8 @@ extern timestamp_t parse_datetime(const char *s); /* returns 0 on error */ extern const char *monthname(int mon); -#ifdef __cplusplus } -#include std::string format_datetime(timestamp_t timestamp); /* ownership of string passed to caller */ #endif - -#endif diff --git a/core/subsurfacestartup.h b/core/subsurfacestartup.h index 6f40f7abd..38028c71b 100644 --- a/core/subsurfacestartup.h +++ b/core/subsurfacestartup.h @@ -2,11 +2,7 @@ #ifndef SUBSURFACESTARTUP_H #define SUBSURFACESTARTUP_H -#ifdef __cplusplus extern "C" { -#else -#include -#endif extern bool imported; extern int quit, force_root, ignore_bt; @@ -19,7 +15,6 @@ void print_version(void); extern char *settings_suffix; -#ifdef __cplusplus } #ifdef SUBSURFACE_MOBILE_DESKTOP @@ -27,6 +22,4 @@ extern char *settings_suffix; extern std::string testqml; #endif -#endif - #endif // SUBSURFACESTARTUP_H diff --git a/core/subsurfacesysinfo.h b/core/subsurfacesysinfo.h index a608239b3..46566a6d5 100644 --- a/core/subsurfacesysinfo.h +++ b/core/subsurfacesysinfo.h @@ -4,9 +4,7 @@ #include #ifdef Q_OS_WIN -#ifdef __cplusplus extern "C" -#endif bool isWin7Or8(); #endif diff --git a/core/tag.h b/core/tag.h index d7288804d..dd3bf10d2 100644 --- a/core/tag.h +++ b/core/tag.h @@ -3,18 +3,13 @@ #ifndef TAG_H #define TAG_H -#include - -#ifdef __cplusplus #include #include #include extern "C" { -#endif struct divetag { -#ifdef __cplusplus /* * The name of the divetag. If a translation is available, name contains * the translated tag @@ -28,7 +23,6 @@ struct divetag { divetag(const char *n, const char *s) : name(n), source(s) { } -#endif }; struct tag_entry { @@ -46,8 +40,6 @@ void taglist_free(struct tag_entry *tag_list); struct tag_entry *taglist_copy(struct tag_entry *s); void taglist_merge(struct tag_entry **dst, struct tag_entry *src1, struct tag_entry *src2); -#ifdef __cplusplus - /* * divetags are only stored once, each dive only contains * a list of tag_entries which then point to the divetags @@ -72,5 +64,3 @@ extern std::string taglist_get_tagstring(struct tag_entry *tag_list); std::string taglist_get_tagstring(struct tag_entry *tag_list); #endif - -#endif diff --git a/core/taxonomy.h b/core/taxonomy.h index 6c61d91e1..f4279066e 100644 --- a/core/taxonomy.h +++ b/core/taxonomy.h @@ -2,8 +2,6 @@ #ifndef TAXONOMY_H #define TAXONOMY_H -#ifdef __cplusplus - #include #include @@ -42,5 +40,4 @@ std::string taxonomy_get_country(const taxonomy_data &t); void taxonomy_set_category(taxonomy_data &t, enum taxonomy_category category, const std::string &value, enum taxonomy_origin origin); void taxonomy_set_country(taxonomy_data &t, const std::string &country, enum taxonomy_origin origin); -#endif #endif // TAXONOMY_H diff --git a/core/trip.h b/core/trip.h index 249fa464c..ec6e743b9 100644 --- a/core/trip.h +++ b/core/trip.h @@ -4,9 +4,7 @@ #include "divelist.h" -#ifdef __cplusplus extern "C" { -#endif typedef struct dive_trip { @@ -60,7 +58,6 @@ void clear_trip_table(struct trip_table *table); extern void dump_trip_list(void); #endif -#ifdef __cplusplus } /* Make pointers to dive_trip and trip_table "Qt metatypes" so that they can be @@ -70,5 +67,3 @@ Q_DECLARE_METATYPE(struct dive_trip *); Q_DECLARE_METATYPE(trip_table_t *); #endif - -#endif diff --git a/core/uemis.h b/core/uemis.h index 860760d0e..e8cb69b69 100644 --- a/core/uemis.h +++ b/core/uemis.h @@ -8,8 +8,6 @@ #include "libdivecomputer.h" // for device_data_t, which is a typedef, not a struct :( -#ifdef __cplusplus - #include #include #include @@ -42,6 +40,4 @@ private: std::string do_uemis_import(device_data_t *data); -#endif - #endif // UEMIS_H diff --git a/core/units.h b/core/units.h index cd77ef483..9a4c98f24 100644 --- a/core/units.h +++ b/core/units.h @@ -7,11 +7,7 @@ #define M_PI 3.14159265358979323846 #endif -#ifdef __cplusplus extern "C" { -#else -#include -#endif #define FRACTION_TUPLE(n, x) ((unsigned)(n) / (x)), ((unsigned)(n) % (x)) #define SIGNED_FRAC_TRIPLET(n, x) ((n) >= 0 ? '+': '-'), ((n) >= 0 ? (unsigned)(n) / (x) : (-(n) / (x))), ((unsigned)((n) >= 0 ? (n) : -(n)) % (x)) @@ -24,11 +20,7 @@ extern "C" { #define SURFACE_PRESSURE 1013 // mbar #define ZERO_C_IN_MKELVIN 273150 // mKelvin -#ifdef __cplusplus #define M_OR_FT(_m, _f) ((prefs.units.length == units::METERS) ? ((_m) * 1000) : (feet_to_mm(_f))) -#else -#define M_OR_FT(_m, _f) ((prefs.units.length == METERS) ? ((_m) * 1000) : (feet_to_mm(_f))) -#endif /* Salinity is expressed in weight in grams per 10l */ #define SEAWATER_SALINITY 10300 @@ -131,11 +123,7 @@ typedef struct typedef struct { -#ifdef __cplusplus int grams = 0; -#else - int grams; -#endif } weight_t; typedef struct @@ -350,8 +338,6 @@ extern double get_vertical_speed_units(unsigned int mms, int *frac, const char * extern depth_t units_to_depth(double depth); extern int units_to_sac(double volume); -#ifdef __cplusplus } -#endif #endif diff --git a/core/uploadDiveLogsDE.h b/core/uploadDiveLogsDE.h index 0259d1fb1..11b99c262 100644 --- a/core/uploadDiveLogsDE.h +++ b/core/uploadDiveLogsDE.h @@ -6,7 +6,6 @@ #include #include - class uploadDiveLogsDE : public QObject { Q_OBJECT @@ -39,4 +38,5 @@ private: QHttpMultiPart *multipart; QTimer timeout; }; + #endif // UPLOADDIVELOGSDE_H diff --git a/core/uploadDiveShare.h b/core/uploadDiveShare.h index fdd941e67..26729b1e9 100644 --- a/core/uploadDiveShare.h +++ b/core/uploadDiveShare.h @@ -4,7 +4,6 @@ #include #include - class uploadDiveShare : public QObject { Q_OBJECT @@ -29,4 +28,5 @@ private: QNetworkReply *reply; QTimer timeout; }; + #endif // UPLOADDIVESHARE_H diff --git a/core/version.h b/core/version.h index 98385e970..a37ec596f 100644 --- a/core/version.h +++ b/core/version.h @@ -1,15 +1,11 @@ #ifndef VERSION_H #define VERSION_H -#ifdef __cplusplus extern "C" { -#endif const char *subsurface_git_version(void); const char *subsurface_canonical_version(void); -#ifdef __cplusplus } -#endif #endif diff --git a/core/webservice.h b/core/webservice.h index 1675a1743..f31d0d007 100644 --- a/core/webservice.h +++ b/core/webservice.h @@ -2,9 +2,7 @@ #ifndef WEBSERVICE_H #define WEBSERVICE_H -#ifdef __cplusplus extern "C" { -#endif //extern void webservice_download_dialog(void); //extern bool webservice_request_user_xml(const gchar *, gchar **, unsigned int *, unsigned int *); @@ -19,7 +17,5 @@ enum { }; -#ifdef __cplusplus } -#endif #endif // WEBSERVICE_H diff --git a/core/worldmap-save.h b/core/worldmap-save.h index f3e2ddd29..46d580f59 100644 --- a/core/worldmap-save.h +++ b/core/worldmap-save.h @@ -2,14 +2,10 @@ #ifndef WORLDMAP_SAVE_H #define WORLDMAP_SAVE_H -#ifdef __cplusplus extern "C" { -#endif extern void export_worldmap_HTML(const char *file_name, bool selected_only); -#ifdef __cplusplus } -#endif #endif diff --git a/core/xmlparams.h b/core/xmlparams.h index 38e175935..0631d3214 100644 --- a/core/xmlparams.h +++ b/core/xmlparams.h @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 // Small helper class that keeps track of key/value pairs to -// pass to the XML-routines as parameters. Uses C++ for memory -// management, but provides a C interface via anonymous struct. +// pass to the XML-routines as parameters. +#ifndef XMLPARAMS_H +#define XMLPARAMS_H -#ifdef __cplusplus #include #include @@ -12,15 +12,7 @@ struct xml_params { mutable std::vector data; }; -#else - -struct xml_params; - -#endif - -#ifdef __cplusplus extern "C" { -#endif // Return values marked as "not stable" may be invalidated when calling // an xml_params_*() function that takes a non-const xml_params parameter. @@ -35,6 +27,6 @@ extern const char *xml_params_get_value(const struct xml_params *params, int idx extern void xml_params_set_value(struct xml_params *params, int idx, const char *value); extern const char **xml_params_get(const struct xml_params *params); // not stable -#ifdef __cplusplus } + #endif