Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26443

The check HAVE_C99_INITIALIZERS is not applicable to C++

    XMLWordPrintable

    Details

      Description

      I think that we should remove the following, rather useless, compile-time check:

      diff --git a/storage/innobase/innodb.cmake b/storage/innobase/innodb.cmake
      index e2e74951f67..b6276f73e31 100644
      --- a/storage/innobase/innodb.cmake
      +++ b/storage/innobase/innodb.cmake
      @@ -228,11 +228,6 @@ ENDIF(NOT MSVC)
       
       CHECK_FUNCTION_EXISTS(vasprintf  HAVE_VASPRINTF)
       
      -CHECK_CXX_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
      -IF(HAVE_C99_INITIALIZERS)
      -  ADD_DEFINITIONS(-DHAVE_C99_INITIALIZERS)
      -ENDIF()
      -
       SET(MUTEXTYPE "event" CACHE STRING "Mutex type: event, sys or futex")
       
       IF(MUTEXTYPE MATCHES "event")
      

      The test program fails to declare a return type, so it should hopefully always fail to compile with a C++ compiler.

      Designated initializers were introduced in ISO/IEC 9899:1999 (C99), but the code base is supposed to be compatible with an earlier version of the standard (C90). The InnoDB code based was switched from C to C++ in MySQL 5.6 and MariaDB 10.0.

      C++ did not introduce syntax for designated initializers until ISO/IEC 14882:2020. MariaDB Server is still stuck with the 2011 or earlier version of the standard.

      Therefore, this check as well as the macro STRUCT_FLD are best removed, to make the declarations easier to read and to slightly reduce the compile time by removing a useless compile-time check.

        Attachments

          Activity

            People

            Assignee:
            marko Marko Mäkelä
            Reporter:
            marko Marko Mäkelä
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration