aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-10-03 05:45:12 -0700
committerChris Robinson <[email protected]>2013-10-03 05:45:12 -0700
commit01a5946a2e371485e4e0774e7dd543ad3a1f0675 (patch)
tree04ef80e1b13c9bbe76c97c1cee108d8a9a1f7ee6
parent2e605590a264b96f08c36f09b1d969cc9808d5ac (diff)
Compile using -std=c99 when available
-rw-r--r--Alc/backends/alsa.c2
-rw-r--r--Alc/backends/portaudio.c2
-rw-r--r--Alc/backends/pulseaudio.c2
-rw-r--r--CMakeLists.txt9
4 files changed, 11 insertions, 4 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index 89227be1..f6c0428e 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -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);
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c
index 2a80bfa6..94311134 100644
--- a/Alc/backends/portaudio.c
+++ b/Alc/backends/portaudio.c
@@ -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);
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index 606630aa..7e137157 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -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);
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f39c910f..4b9d3ba4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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>