Require C99 for Cactus C thorns

Issue #1128 closed
Ian Hinder created an issue

According to Erik, all systems that we need to support have good support for C99. Many thorns use some features of C99, and it is a common error to try to compile these without using the C99 options to a compiler. The resulting error messages can be confusing.

In order to provide a common language platform for Cactus thorn writers, we should state that Cactus expects the compiler to have C99 enabled. We should test this during the configure stage and abort with a good error message if it is not the case. Thorn writers can then assume the standard features of C99 will always be available.

The automatically-configured compiler options in known_architectures should be modified to enable C99 mode if it is not enabled by default for all the recognised compilers.

Keyword:

Comments (5)

  1. Ian Hinder reporter
    • removed comment

    Does it abort if it is not available? If not, where would be a good place to put this? At the same time, we should modify known_architectures to add the required flags for the common compilers, otherwise a straightforward "make" with no optionlist will probably fail.

  2. Erik Schnetter
    • removed comment

    Yes, this aborts if C99 is not available:

    CCTK_CHECK_C99
    if test "$cctk_cv_have_c99" = "no" ; then
      echo "Cactus requires a C99 compiler -- check your C compiler and C compiler flags"
      exit 1
    fi
    
  3. Ian Hinder reporter
    • changed status to resolved
    • removed comment

    According to http://gcc.gnu.org/onlinedocs/gcc/Standards.html,

    The default, if no C language dialect options are given, is -std=gnu90; this will change to -std=gnu99 or -std=gnu11 in some future release when the C99 or C11 support is complete.

    I very much want the user to be able to compile using gcc without having to specify an optionlist. Now that I check this, it looks like Cactus enables C99 plus GNU extensions if the compiler is called "gcc" or "cc":

    From lib/make/known-architectures/linux:

     # C compiler
     # Set the appropriate dependency, warning, and debugging flags
     # Note that the defaults settings are for gcc/g++ and set by configure
     case `basename $CC` in
       # GNU
       gcc | cc)
         : ${CFLAGS='-pipe -std=gnu99'}
    

    The same applies to darwin. Assuming I am interpreting this code correctly, this is what I wanted.

    For linux, the intel compiler is also invoked with C99 by default, though for darwin it looks like it is not. I'm not so worried about the intel compiler, as it will never be automatically chosen by Cactus, so the user needs to do something anyway.

  4. Log in to comment