commit c3bbca775feb912ff3d78c40a86a461034dd1340
parent c8a8f4d1023c7ba4fca2f979e454c42f5747dd06
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 3 Jul 2026 12:03:41 +0200
refactor(headers): add C++ linkage guards, drop unused global sim declaration
Diffstat:
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/arrays.h b/arrays.h
@@ -3,6 +3,10 @@
#include <stdio.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
unsigned int idx3(
const unsigned int i, const unsigned int j, const unsigned int k,
const unsigned int nx, const unsigned int ny);
@@ -57,4 +61,8 @@ double euclidean_distance(const double *a, const double *b, const int n);
double dot(const double *a, const double *b, const int n);
double * cross(const double a[3], const double b[3]);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/fluid.h b/fluid.h
@@ -3,7 +3,9 @@
#include "simulation.h"
-extern struct simulation sim;
+#ifdef __cplusplus
+extern "C" {
+#endif
void hydrostatic_fluid_pressure_distribution(struct simulation *sim);
@@ -13,4 +15,8 @@ int darcy_solver_1d(struct simulation *sim);
void add_darcy_iters(int iters);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/simulation.c b/simulation.c
@@ -23,6 +23,7 @@ struct solver_stats {
long timesteps;
};
+/* per-process counters; not thread-safe if columns run on multiple threads */
static struct solver_stats g_stats = {0, 0, 0, 0, 0};
/* lower limit for effective normal stress sigma_n_eff for granular solver */
diff --git a/simulation.h b/simulation.h
@@ -7,7 +7,9 @@
#define PI 3.14159265358979323846
#define DEG2RAD(x) (x * PI / 180.0)
-extern struct simulation sim;
+#ifdef __cplusplus
+extern "C" {
+#endif
/* Simulation settings */
struct simulation {
@@ -186,4 +188,8 @@ void tridiagonal_solver(double *x, const double *a, const double *b,
const double *c, const double *d, double *c_prime,
double *d_prime, int n);
+#ifdef __cplusplus
+}
+#endif
+
#endif