Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundled CVODE contains CMake script with C99 compatibility issue #262

Open
fweimer-rh opened this issue Dec 11, 2022 · 1 comment
Open

Comments

@fweimer-rh
Copy link

The C/Fortran linking test always fails with C compilers which do not implement implicit function declarations (a language feature removed in C99; future compilers are likely to disable them by default because they are a programmer hazard). Something like this is needed:

diff -up bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake.c99 bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake
--- bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake.c99	2009-05-10 02:02:59.000000000 +0200
+++ bionetgen-BioNetGen-2.8.4/bng2/Network3/cvode-2.6.0/config/SundialsFortran.cmake	2022-12-11 18:44:28.015918587 +0100
@@ -111,7 +111,7 @@ if(CMAKE_Fortran_COMPILER)
       # Get the current list entry (current scheme)
       list(GET options ${iopt} opt)
       # Generate C source which calls the "mysub" function using the current scheme
-      file(WRITE ${FortranTest_DIR}/ctest1.c "int main(){${opt}();return(0);}\n")
+      file(WRITE ${FortranTest_DIR}/ctest1.c "char ${opt}(void); int main(){${opt}();return(0);}\n")
       # Use TRY_COMPILE to make the "ctest1" executable from the current C source
       # and linking to the previously created "flib" library.
       try_compile(CTEST_OK ${FortranTest_DIR} ${FortranTest_DIR}
@@ -149,7 +149,7 @@ if(CMAKE_Fortran_COMPILER)
     set(iopt 0)
     while(${iopt} LESS ${imax})   
       list(GET options ${iopt} opt)
-      file(WRITE ${FortranTest_DIR}/ctest2.c "int main(){${opt}();return(0);}\n")
+      file(WRITE ${FortranTest_DIR}/ctest2.c "char ${opt}(void); int main(){${opt}();return(0);}\n")
       try_compile(CTEST_OK ${FortranTest_DIR} ${FortranTest_DIR}
         ctest2 OUTPUT_VARIABLE MY_OUTPUT)
       file(REMOVE_RECURSE ${FortranTest_DIR}/CMakeFiles)

Ordinarily I would send a PR, but the sources are contained in a tarball in the repository. I couldn't find any pre-existing patches.

Upstream CVODE has resolved it in pretty much the same way (although they use void ${opt}(void);; the char return type is the autoconf way).

Found as part of:

@ASinanSaglam
Copy link
Collaborator

I will take a look at this very soon, sorry for the delay and thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants