core: remove __cplusplus ifdefs

Since all source files are now C++, this is redundant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-04 17:55:50 +02:00 committed by bstoeger
parent 9065bf8622
commit 03b910ee7f
55 changed files with 37 additions and 347 deletions

View file

@ -5,10 +5,9 @@
#include "units.h"
#include "gas.h"
#include "divemode.h"
#include <memory>
#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 <memory>
struct deco_state_cache {
// Test if there is cached data
operator bool () {
@ -87,6 +82,4 @@ private:
std::unique_ptr<deco_state> data;
};
#endif
#endif // DECO_H

View file

@ -3,10 +3,10 @@
#define DEVICE_H
#include <stdint.h>
#include <string>
#include <vector>
#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 <string>
#include <vector>
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

View file

@ -11,11 +11,9 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef __cplusplus
#include <string>
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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -7,7 +7,6 @@
#include "divelist.h"
#include <stdlib.h>
#ifdef __cplusplus
#include <QObject>
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

View file

@ -4,9 +4,11 @@
#include "gas.h"
#ifdef __cplusplus
#include <memory>
#include <string>
#include <vector>
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 <memory>
#include <string>
#include <vector>
struct ws_info {
std::string name;
weight_t weight;
@ -135,6 +132,4 @@ extern std::pair<volume_t, pressure_t> get_tank_info_data(const std::vector<tank
extern void add_cylinder_description(const cylinder_type_t &);
extern void reset_tank_info_table(std::vector<tank_info> &table);
#endif
#endif // EQUIPMENT_H

View file

@ -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

View file

@ -8,9 +8,7 @@
#include <libdivecomputer/parser.h>
#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

View file

@ -3,9 +3,10 @@
#ifndef EVENTNAME_H
#define EVENTNAME_H
#ifdef __cplusplus
#include <vector>
#include <QString>
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 <vector>
#include <QString>
extern std::vector<int> hidden_event_types();
QString event_type_name(const event *ev);
QString event_type_name(int idx);
#endif
#endif

View file

@ -6,13 +6,13 @@
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <utility>
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 <vector>
#include <utility>
// return data, errorcode pair.
extern std::pair<std::string, int> 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

View file

@ -5,15 +5,11 @@
#define FILTER_CONSTRAINT_H
#include "units.h"
#include <QStringList>
struct dive;
#ifdef __cplusplus
#include <QStringList>
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

View file

@ -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 <vector>
#include <string>
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<filter_preset>
{
};
#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

View file

@ -7,12 +7,10 @@
#define __printf(x, y)
#endif
#ifdef __cplusplus
#include <QString>
__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

View file

@ -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 <QString>
#include <vector>
@ -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

View file

@ -5,11 +5,7 @@
#include "divemode.h"
#include "units.h"
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#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

View file

@ -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

View file

@ -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

View file

@ -4,14 +4,14 @@
#include "git2.h"
#include "filterpreset.h"
#include <string>
struct dive_log;
struct git_oid;
struct git_repository;
struct divelog;
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#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 <string>
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

View file

@ -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

View file

@ -4,6 +4,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string>
/* libdivecomputer */
@ -20,9 +21,6 @@
#define dc_usb_storage_open(stream, context, devname) (DC_STATUS_UNSUPPORTED)
#endif
#ifdef __cplusplus
#include <string>
extern "C" {
struct dive;
@ -76,6 +74,5 @@ extern std::string logfile_name;
extern std::string dumpfile_name;
}
#endif
#endif // LIBDIVECOMPUTER_H

View file

@ -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

View file

@ -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

View file

@ -2,8 +2,6 @@
#ifndef NAMECMP_H
#define NAMECMP_H
#ifdef __cplusplus
#include <QXmlStreamReader>
// 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

View file

@ -12,6 +12,7 @@
#include <memory>
#include <sqlite3.h>
#include <string>
#include <time.h>
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 <string>
std::string trimspace(const char *buffer);
#endif
#endif

View file

@ -6,9 +6,7 @@
#include "units.h"
#include <stddef.h> // 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

View file

@ -4,6 +4,7 @@
#include "units.h"
#include "divemode.h"
#include <string>
/* 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 <string>
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

View file

@ -5,11 +5,7 @@
#include "units.h"
#include "taxonomy.h"
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#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

View file

@ -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<int, std::vector<std::string>> get_plot_details_new(const struct dive *d, const struct plot_info &pi, int time);
std::vector<std::string> compare_samples(const struct dive *d, const struct plot_info &pi, int idx1, int idx2, bool sum);
#endif
#endif // PROFILE_H

View file

@ -21,7 +21,6 @@
class BLEObject : public QObject
{
Q_OBJECT
public:
BLEObject(QLowEnergyController *c, device_data_t &);
~BLEObject();

View file

@ -17,8 +17,6 @@ enum watertypes {FRESHWATER, BRACKISHWATER, EN13319WATER, SALTWATER, DC_WATERTYP
// 2) Functions visible only to C++ parts
#ifdef __cplusplus
#include <QString>
#include <optional>
#include <string>
@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 <vector>
#include <QVector>
@ -64,6 +59,4 @@ std::vector<dive *> getDiveSelection();
bool diveInSelection(const std::vector<dive *> &selection, const dive *d);
void updateSelection(std::vector<dive *> &selection, const std::vector<dive *> &add, const std::vector<dive *> &remove);
#endif // __cplusplus
#endif // SELECTION_H

View file

@ -8,8 +8,6 @@
#ifndef SHA1_H
#define SHA1_H
#ifdef __cplusplus
#include <array>
#include <string>
@ -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

View file

@ -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

View file

@ -18,8 +18,6 @@
struct dive;
#ifdef __cplusplus
#include <string>
#include <vector>
@ -66,6 +64,4 @@ extern stats_t calculate_stats_selected();
extern std::vector<volume_t> get_gas_used(struct dive *dive);
extern std::pair<volume_t, volume_t> selected_dives_gas_parts(); // returns (O2, He) tuple
#endif
#endif // STATISTICS_H

View file

@ -4,10 +4,6 @@
#include <math.h>
#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

View file

@ -5,10 +5,11 @@
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include <string>
#include <string_view>
#include <vector>
#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 <string>
#include <string_view>
#include <vector>
// 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<std::string> &l, const std::string &separator, bool skip_empty = false);
#endif
#endif // SUBSURFACE_STRING_H

View file

@ -3,11 +3,10 @@
#define TIME_H
#include "units.h"
#include <string>
#include <time.h>
#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 <string>
std::string format_datetime(timestamp_t timestamp); /* ownership of string passed to caller */
#endif
#endif

View file

@ -2,11 +2,7 @@
#ifndef SUBSURFACESTARTUP_H
#define SUBSURFACESTARTUP_H
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#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

View file

@ -4,9 +4,7 @@
#include <QtGlobal>
#ifdef Q_OS_WIN
#ifdef __cplusplus
extern "C"
#endif
bool isWin7Or8();
#endif

View file

@ -3,18 +3,13 @@
#ifndef TAG_H
#define TAG_H
#include <stdbool.h>
#ifdef __cplusplus
#include <memory>
#include <string>
#include <vector>
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

View file

@ -2,8 +2,6 @@
#ifndef TAXONOMY_H
#define TAXONOMY_H
#ifdef __cplusplus
#include <string>
#include <vector>
@ -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

View file

@ -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

View file

@ -8,8 +8,6 @@
#include "libdivecomputer.h" // for device_data_t, which is a typedef, not a struct :(
#ifdef __cplusplus
#include <string>
#include <string_view>
#include <unordered_map>
@ -42,6 +40,4 @@ private:
std::string do_uemis_import(device_data_t *data);
#endif
#endif // UEMIS_H

View file

@ -7,11 +7,7 @@
#define M_PI 3.14159265358979323846
#endif
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#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

View file

@ -6,7 +6,6 @@
#include <QTimer>
#include <QFile>
class uploadDiveLogsDE : public QObject {
Q_OBJECT
@ -39,4 +38,5 @@ private:
QHttpMultiPart *multipart;
QTimer timeout;
};
#endif // UPLOADDIVELOGSDE_H

View file

@ -4,7 +4,6 @@
#include <QNetworkReply>
#include <QTimer>
class uploadDiveShare : public QObject {
Q_OBJECT
@ -29,4 +28,5 @@ private:
QNetworkReply *reply;
QTimer timeout;
};
#endif // UPLOADDIVESHARE_H

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 <string>
#include <vector>
@ -12,15 +12,7 @@ struct xml_params {
mutable std::vector<const char *> 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