Skip to content

Commit 8350ea0

Browse files
author
Jan Lindström
committed
Fix compiler error if compiler does not support c99 style
initializers.
1 parent f704b33 commit 8350ea0

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

storage/innobase/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
144144
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
145145
ENDIF()
146146

147+
CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
148+
147149
ENDIF(NOT MSVC)
148150

149151
# Solaris atomics

storage/innobase/handler/i_s.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,13 @@ do { \
157157
} \
158158
} while (0)
159159

160-
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && !defined __INTEL_COMPILER
160+
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && !defined __INTEL_COMPILER && !defined __clang__
161+
#ifdef HAVE_C99_INITIALIZERS
161162
#define STRUCT_FLD(name, value) .name = value
162163
#else
164+
#define STRUCT_FLD(name, value) name: value
165+
#endif /* HAVE_C99_INITIALIZERS */
166+
#else
163167
#define STRUCT_FLD(name, value) value
164168
#endif
165169

storage/xtradb/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
180180
ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
181181
ENDIF()
182182

183+
CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS)
184+
183185
ENDIF(NOT MSVC)
184186

185187
# Solaris atomics

storage/xtradb/handler/i_s.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,13 @@ do { \
178178
} \
179179
} while (0)
180180

181-
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && \
182-
!defined __INTEL_COMPILER && !defined __clang__
181+
#if !defined __STRICT_ANSI__ && defined __GNUC__ && (__GNUC__) > 2 && !defined __INTEL_COMPILER && !defined __clang__
182+
#ifdef HAVE_C99_INITIALIZERS
183183
#define STRUCT_FLD(name, value) .name = value
184184
#else
185+
#define STRUCT_FLD(name, value) name: value
186+
#endif /* HAVE_C99_INITIALIZERS */
187+
#else
185188
#define STRUCT_FLD(name, value) value
186189
#endif
187190

0 commit comments

Comments
 (0)