From 8f1a0b84a6f71652bb43a2ee96438ac675bae0b3 Mon Sep 17 00:00:00 2001 From: Milan Skocic Date: Thu, 30 Nov 2023 07:08:23 +0100 Subject: [PATCH] BUG: Fix missing Header guard in C header. --- include/codata.h | 4 ++++ srcgen/c_code.f90 | 12 ++++++++++++ srcgen/main.f90 | 2 ++ 3 files changed, 18 insertions(+) diff --git a/include/codata.h b/include/codata.h index d65a77e..e578984 100644 --- a/include/codata.h +++ b/include/codata.h @@ -3,6 +3,8 @@ * @brief Codata module - autogenerated. */ +#ifndef CODATA_H +#define CODATA_H #if _MSC_VER #define ADD_IMPORT __declspec(dllimport) #else @@ -1072,3 +1074,5 @@ ADD_IMPORT extern const double U_WIEN_WAVELENGTH_DISPLACEMENT_LAW_CONSTANT;/**< ADD_IMPORT extern const double W_TO_Z_MASS_RATIO;/**< */ ADD_IMPORT extern const double U_W_TO_Z_MASS_RATIO;/**< */ +#endif + diff --git a/srcgen/c_code.f90 b/srcgen/c_code.f90 index 4babd98..376320e 100644 --- a/srcgen/c_code.f90 +++ b/srcgen/c_code.f90 @@ -14,6 +14,8 @@ subroutine write_c_header_doc(fcode) write(fcode, "(A) ") '* @brief Codata module - autogenerated.' write(fcode, "(A)") "*/" write(fcode, "(A)") "" + write(fcode, "(A)") '#ifndef CODATA_H' + write(fcode, "(A)") '#define CODATA_H' write(fcode, "(A)") "#if _MSC_VER" write(fcode, "(A)") "#define ADD_IMPORT __declspec(dllimport)" write(fcode, "(A)") "#else" @@ -21,5 +23,15 @@ subroutine write_c_header_doc(fcode) write(fcode, "(A)") "#endif" end subroutine +subroutine write_C_header_end(fcode) + !! Generate the C header declaration + implicit none + ! Arguments + integer(int32), intent(in) :: fcode + !! File unit of the C header. + write(fcode, "(A)") '#endif' + write(fcode, "(A)") '' +end subroutine + end module \ No newline at end of file diff --git a/srcgen/main.f90 b/srcgen/main.f90 index 31d7e17..3d46877 100644 --- a/srcgen/main.f90 +++ b/srcgen/main.f90 @@ -80,6 +80,8 @@ program generator print *, "Writing fortran module end..." call write_fortran_module_end(ffortran) + print *, "Writing C header end..." + call write_C_header_end(fcheader) print *, "Writing cpython end..." call write_cpython_extension_end(fcpython);