Compile using -std=c99 when available

This commit is contained in:
Chris Robinson
2013-10-03 05:45:12 -07:00
parent 2e605590a2
commit 01a5946a2e
4 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ static const ALCchar alsaDevice[] = "ALSA Default";
#ifdef HAVE_DYNLOAD
static void *alsa_handle;
#define MAKE_FUNC(f) static typeof(f) * p##f
#define MAKE_FUNC(f) static __typeof(f) * p##f
MAKE_FUNC(snd_strerror);
MAKE_FUNC(snd_pcm_open);
MAKE_FUNC(snd_pcm_close);
+1 -1
View File
@@ -35,7 +35,7 @@ static const ALCchar pa_device[] = "PortAudio Default";
#ifdef HAVE_DYNLOAD
static void *pa_handle;
#define MAKE_FUNC(x) static typeof(x) * p##x
#define MAKE_FUNC(x) static __typeof(x) * p##x
MAKE_FUNC(Pa_Initialize);
MAKE_FUNC(Pa_Terminate);
MAKE_FUNC(Pa_GetErrorText);
+1 -1
View File
@@ -39,7 +39,7 @@
#ifdef HAVE_DYNLOAD
static void *pa_handle;
#define MAKE_FUNC(x) static typeof(x) * p##x
#define MAKE_FUNC(x) static __typeof(x) * p##x
MAKE_FUNC(pa_context_unref);
MAKE_FUNC(pa_sample_spec_valid);
MAKE_FUNC(pa_frame_size);
+8 -1
View File
@@ -100,10 +100,17 @@ CHECK_TYPE_SIZE("long" SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
CHECK_C_COMPILER_FLAG(-std=c99 HAVE_STD_C99)
IF(HAVE_STD_C99)
SET(CMAKE_C_FLAGS "-std=c99 ${CMAKE_C_FLAGS}")
ENDIF()
# TODO: Once we truly require C99, these restrict and inline checks should go
# away. Currently they're needed to maintain MSVC compatibility.
CHECK_C_SOURCE_COMPILES("int *restrict foo;
int main() {return 0;}" HAVE_RESTRICT)
IF(NOT HAVE_RESTRICT)
# Slightly convoluted way to do this, because MSVC may barf is restrict is
# Slightly convoluted way to do this, because MSVC may barf if restrict is
# defined to __restrict.
CHECK_C_SOURCE_COMPILES("#define restrict __restrict
#include <stdlib.h>