Skip to content

Commit f9f9952

Browse files
authored
Bind C warnings (nasa#49)
Using const cea_real[] instead of const cea_array makes it easier to pass data to the inface without generating incompatible pointer type warnings. It also better reflects the design intent; not only will the pointer not be changed, but the data pointed to will not be changed. Updated example 9 to demonstrate that this works without warnings for both const and non-const data.
1 parent 3bbe516 commit f9f9952

File tree

3 files changed

+186
-178
lines changed

3 files changed

+186
-178
lines changed

.github/workflows/basic_build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ jobs:
379379
fcompiler: intel-classic
380380
fversion: "2021.9"
381381
- os: windows-latest
382-
toolchain:
382+
toolchain:
383383
ccompiler: msvc
384384
cversion: latest
385385
fcompiler: intel
@@ -405,7 +405,7 @@ jobs:
405405
path: extern/gfe
406406
submodules: true
407407

408-
- name: Set up Fortran compiler
408+
- name: Set up Fortran compiler
409409
if: ${{ runner.os != 'Windows' || matrix.toolchain.fcompiler != 'gcc' }}
410410
uses: fortran-lang/setup-fortran@v1
411411
with:
@@ -464,7 +464,7 @@ jobs:
464464
cmake --build build/extern/gfe --target install
465465
466466
- name: Configure (linux)
467-
if: ${{runner.os != 'Windows' || matrix.toolchain.ccompiler != 'msvc'}}
467+
if: ${{runner.os != 'Windows' || matrix.toolchain.ccompiler != 'msvc'}}
468468
run: |
469469
cmake -S . -B build -G Ninja \
470470
-DCMAKE_PREFIX_PATH=build/install \
@@ -504,6 +504,6 @@ jobs:
504504
if: runner.os == 'Windows'
505505
run: |
506506
./build/source/cea.exe -h
507-
507+
508508
- name: Run ctest
509509
run: ctest --test-dir build --output-on-failure

source/bind/c/cea.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,15 @@ extern "C"
303303
const cea_equilibrium_type type,
304304
const cea_real state1,
305305
const cea_real state2,
306-
const cea_array amounts,
306+
const cea_real amounts[],
307307
cea_eqsolution soln);
308308

309309
cea_err cea_eqsolver_solve_with_partials(
310310
const cea_eqsolver solver,
311311
const cea_equilibrium_type type,
312312
const cea_real state1,
313313
const cea_real state2,
314-
const cea_array amounts,
314+
const cea_real amounts[],
315315
cea_eqsolution soln,
316316
cea_eqpartials eqpartials);
317317

@@ -430,14 +430,14 @@ extern "C"
430430
cea_err cea_rocket_solver_solve_iac(
431431
const cea_rocket_solver solver,
432432
cea_rocket_solution soln,
433-
const cea_array weights,
433+
const cea_real weights[],
434434
const cea_real pc,
435435
// Optional: ignored when n_pi_p == 0 (pi_p may be NULL)
436-
const cea_array pi_p,
436+
const cea_real pi_p[],
437437
const cea_int n_pi_p,
438-
const cea_array subar,
438+
const cea_real subar[],
439439
const cea_int nsubar,
440-
const cea_array supar,
440+
const cea_real supar[],
441441
const cea_int nsupar,
442442
const cea_int n_frz,
443443
const cea_real hc_or_tc,
@@ -448,14 +448,14 @@ extern "C"
448448
cea_err cea_rocket_solver_solve_fac(
449449
const cea_rocket_solver solver,
450450
cea_rocket_solution soln,
451-
const cea_array weights,
451+
const cea_real weights[],
452452
const cea_real pc,
453453
// Optional: ignored when n_pi_p == 0 (pi_p may be NULL)
454-
const cea_array pi_p,
454+
const cea_real pi_p[],
455455
const cea_int n_pi_p,
456-
const cea_array subar,
456+
const cea_real subar[],
457457
const cea_int nsubar,
458-
const cea_array supar,
458+
const cea_real supar[],
459459
const cea_int nsupar,
460460
const cea_int n_frz,
461461
const cea_real hc_or_tc,
@@ -554,7 +554,7 @@ extern "C"
554554
cea_err cea_shock_solver_solve(
555555
const cea_shock_solver solver,
556556
cea_shock_solution soln,
557-
const cea_array weights,
557+
const cea_real weights[],
558558
const cea_real T0,
559559
const cea_real p0,
560560
const cea_real mach1_or_u1,
@@ -640,7 +640,7 @@ extern "C"
640640
cea_err cea_detonation_solver_solve(
641641
const cea_detonation_solver solver,
642642
cea_detonation_solution soln,
643-
const cea_array weights,
643+
const cea_real weights[],
644644
const cea_real T1,
645645
const cea_real p1,
646646
const bool frozen);

0 commit comments

Comments
 (0)