From 0dc35c8d38c8d59ab69362299e76610c3b1ca045 Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 8 Dec 2009 09:48:00 +0000 Subject: [PATCH] John Denker: Suggestion: It might be helpful to promote each of the .c files to .cxx. Rationale: -- The configure/makefile system handles CFLAGS differently from CXXFLAGS. -- It is important for the *info programs to compiled and run in exactly the same environment as the main fgfs program. Some users depend on compiler or linker flags such as rpath that strongly affect the results of the *info programs. -- There is no downside; you code compiles just fine as-is under the c++ compiler. second part of the original commit, for ehofman/sound --- tests/Makefile.am | 2 +- tests/{alcinfo.c => alcinfo.cxx} | 33 ++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 15 deletions(-) rename tests/{alcinfo.c => alcinfo.cxx} (91%) diff --git a/tests/Makefile.am b/tests/Makefile.am index 57a0bd77c..87d87c7ec 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,7 +8,7 @@ est_epsilon_LDADD = $(opengl_LIBS) gl_info_SOURCES = gl-info.c gl_info_LDADD = $(opengl_LIBS) -alcinfo_SOURCES = alcinfo.c +alcinfo_SOURCES = alcinfo.cxx alcinfo_LDADD = $(openal_LIBS) test_env_map_SOURCES = test-env-map.cxx diff --git a/tests/alcinfo.c b/tests/alcinfo.cxx similarity index 91% rename from tests/alcinfo.c rename to tests/alcinfo.cxx index acc40a22d..2f569390d 100644 --- a/tests/alcinfo.c +++ b/tests/alcinfo.cxx @@ -36,6 +36,9 @@ #include #include #include +#include + +using std::string; #ifndef ALC_ALL_DEVICES_SPECIFIER # define ALC_ALL_DEVICES_SPECIFIER 0x1013 @@ -48,7 +51,7 @@ static const int maxmimumWidth = 79; void printExtensions (const char *, char, const char *); void displayDevices(const char *, const char *); char *getDeviceName(int, char **); -void testForError(void *, char *); +void testForError(void *, const string&); void testForALCError(ALCdevice *); int main(int argc, char **argv) @@ -96,21 +99,23 @@ int main(int argc, char **argv) alcGetIntegerv(device, ALC_FREQUENCY, 1, data); printf("mixer frequency: %u hz\n", data[0]); - testForError(device, "invalid context"); + testForALCError(device); alcGetIntegerv(device, ALC_REFRESH, 1, data+1); printf("refresh rate : %u hz\n", data[0]/data[1]); - testForError(device, "invalid context"); + testForALCError(device); data[0] = 0; alcGetIntegerv(device, ALC_MONO_SOURCES, 1, data); - printf("supported sources; mono: %u, ", data[0]); - testForError(device, "invalid context"); + error = alcGetError(device); + if (error == AL_NONE) { + printf("supported sources; mono: %u, ", data[0]); - data[0] = 0; - alcGetIntegerv(device, ALC_STEREO_SOURCES, 1, data); - printf("stereo: %u\n", data[0]); - testForError(device, "invalid context"); + data[0] = 0; + alcGetIntegerv(device, ALC_STEREO_SOURCES, 1, data); + printf("stereo: %u\n", data[0]); + testForALCError(device); + } printf("ALC version: "); alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, data); @@ -248,15 +253,15 @@ printExtensions (const char *header, char separator, const char *extensions) } char * -getCommandLineOption(int argc, char **argv, char *option) +getCommandLineOption(int argc, char **argv, const string& option) { - int slen = strlen(option); + int slen = option.size(); char *rv = 0; int i; for (i=0; i