Skip to content

Commit 3832bda

Browse files
author
Jan Lindström
committed
Fix compiler error if compiler does not support c99 style
initializers.
1 parent 7ed673f commit 3832bda

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

mysql-test/suite/innodb/t/innodb_skip_innodb_is_tables.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
--source include/not_embedded.inc
12

23
select * from information_schema.innodb_trx;
34
select * from information_schema.innodb_locks;

storage/innobase/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
210210
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
211211
ENDIF()
212212

213+
CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
214+
213215
ENDIF(NOT MSVC)
214216

215217
CHECK_FUNCTION_EXISTS(asprintf HAVE_ASPRINTF)

storage/innobase/handler/i_s.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ do { \
8585
} \
8686
} while (0)
8787

88-
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && \
89-
!defined __INTEL_COMPILER && !defined __clang__
88+
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && !defined __INTEL_COMPILER && !defined __clang__
89+
#ifdef HAVE_C99_INITIALIZERS
9090
#define STRUCT_FLD(name, value) .name = value
9191
#else
92+
#define STRUCT_FLD(name, value) name: value
93+
#endif /* HAVE_C99_INITIALIZERS */
94+
#else
9295
#define STRUCT_FLD(name, value) value
9396
#endif
9497

storage/xtradb/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
219219
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
220220
ENDIF()
221221

222+
CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
223+
222224
ENDIF(NOT MSVC)
223225

224226
CHECK_FUNCTION_EXISTS(asprintf HAVE_ASPRINTF)

storage/xtradb/handler/i_s.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ do { \
8989
} \
9090
} while (0)
9191

92-
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && \
93-
!defined __INTEL_COMPILER && !defined __clang__
92+
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && !defined __INTEL_COMPILER && !defined __clang__
93+
#ifdef HAVE_C99_INITIALIZERS
9494
#define STRUCT_FLD(name, value) .name = value
9595
#else
96+
#define STRUCT_FLD(name, value) name: value
97+
#endif /* HAVE_C99_INITIALIZERS */
98+
#else
9699
#define STRUCT_FLD(name, value) value
97100
#endif
98101

0 commit comments

Comments
 (0)