SDL_power.c: Adjust SDL_POWER_DISABLED ifdefs to avoid zero-size array Otherwise if SDL_POWER_DISABLED is disabled (eg with --disable-power): ... with clang -pedantic: src/power/SDL_power.c:48:50: warning: use of GNU empty initializer extension [-Wgnu-empty-initializer] static SDL_GetPowerInfo_Impl implementations[] = { ^ src/power/SDL_power.c:48:50: warning: zero size arrays are an extension [-Wzero-length-array] 2 warnings generated. ... with gcc -pedantic: src/power/SDL_power.c:48:50: warning: ISO C forbids empty initializer braces [-Wpedantic] src/power/SDL_power.c:48:50: warning: ISO C forbids empty initializer braces [-Wpedantic] static SDL_GetPowerInfo_Impl implementations[] = { ^ src/power/SDL_power.c:48:30: error: zero or negative size array ?implementations? static SDL_GetPowerInfo_Impl implementations[] = { ^~~~~~~~~~~~~~~ ... with Watcom: ./src/power/SDL_power.c(85): Error! E1112: Initializer list cannot be empty
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
diff --git a/OWMakefile.os2 b/OWMakefile.os2
index 1bba8c3..e709835 100644
--- a/OWMakefile.os2
+++ b/OWMakefile.os2
@@ -19,15 +19,6 @@ CFLAGS+= $(INCPATH)
# building SDL itself:
CFLAGS+= -DBUILD_SDL
-# this is so that build doesn't fail with E1112:
-#CFLAGS+= -DSDL_POWER_DISABLED
-CFLAGS+= -DSDL_POWER_HARDWIRED
-
-.extensions:
-.extensions: .lib .dll .obj .c .asm
-
-.c: ./src;./src/dynapi;./src/audio;./src/cpuinfo;./src/events;./src/file;./src/haptic;./src/joystick;./src/power;./src/render;./src/render/software;./src/sensor;./src/stdlib;./src/thread;./src/timer;./src/video;./src/video/yuv2rgb;./src/haptic/dummy;./src/joystick/dummy;./src/loadso/dummy;./src/filesystem/dummy;./src/thread/generic;./src/timer/dummy;./src/power;./src/power/os2;./src/atomic;./src/audio/dummy;./src/audio/disk;./src/video/dummy;./src/sensor/dummy;./src/test;
-
SRCS = SDL.c SDL_assert.c SDL_error.c SDL_log.c SDL_dataqueue.c SDL_hints.c
SRCS+= SDL_getenv.c SDL_iconv.c SDL_malloc.c SDL_qsort.c SDL_stdlib.c SDL_string.c
SRCS+= SDL_cpuinfo.c SDL_atomic.c SDL_spinlock.c SDL_thread.c SDL_timer.c
@@ -58,6 +49,11 @@ SRCS+= SDL_dynapi.c
OBJS = $(SRCS:.c=.obj)
+.extensions:
+.extensions: .lib .dll .obj .c .asm
+
+.c: ./src;./src/dynapi;./src/audio;./src/cpuinfo;./src/events;./src/file;./src/haptic;./src/joystick;./src/power;./src/render;./src/render/software;./src/sensor;./src/stdlib;./src/thread;./src/timer;./src/video;./src/video/yuv2rgb;./src/haptic/dummy;./src/joystick/dummy;./src/loadso/dummy;./src/filesystem/dummy;./src/thread/generic;./src/timer/dummy;./src/power;./src/power/os2;./src/atomic;./src/audio/dummy;./src/audio/disk;./src/video/dummy;./src/sensor/dummy;./src/test;
+
all: $(DLLFILE) $(LIBFILE) .symbolic
$(DLLFILE): $(OBJS) $(LNKFILE)
diff --git a/include/SDL_config_os2.h b/include/SDL_config_os2.h
index eb1d7d4..d1e4bb2 100644
--- a/include/SDL_config_os2.h
+++ b/include/SDL_config_os2.h
@@ -28,6 +28,7 @@
#define SDL_AUDIO_DRIVER_DUMMY 1
#define SDL_AUDIO_DRIVER_DISK 1
+#define SDL_POWER_DISABLED 1
#define SDL_JOYSTICK_DISABLED 1
#define SDL_HAPTIC_DISABLED 1
/*#undef SDL_JOYSTICK_HIDAPI */
diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c
index e09e27b..de77c09 100644
--- a/src/power/SDL_power.c
+++ b/src/power/SDL_power.c
@@ -42,11 +42,8 @@ SDL_GetPowerInfo_Hardwired(SDL_PowerState * state, int *seconds, int *percent)
return SDL_TRUE;
}
#endif
-#endif
-
static SDL_GetPowerInfo_Impl implementations[] = {
-#ifndef SDL_POWER_DISABLED
#ifdef SDL_POWER_LINUX /* in order of preference. More than could work. */
SDL_GetPowerInfo_Linux_org_freedesktop_upower,
SDL_GetPowerInfo_Linux_sys_class_power_supply,
@@ -81,31 +78,34 @@ static SDL_GetPowerInfo_Impl implementations[] = {
#ifdef SDL_POWER_HARDWIRED
SDL_GetPowerInfo_Hardwired,
#endif
-#endif
};
+#endif
SDL_PowerState
SDL_GetPowerInfo(int *seconds, int *percent)
{
+#ifndef SDL_POWER_DISABLED
const int total = sizeof(implementations) / sizeof(implementations[0]);
- int _seconds, _percent;
SDL_PowerState retval = SDL_POWERSTATE_UNKNOWN;
int i;
+#endif
+ int _seconds, _percent;
/* Make these never NULL for platform-specific implementations. */
if (seconds == NULL) {
seconds = &_seconds;
}
-
if (percent == NULL) {
percent = &_percent;
}
+#ifndef SDL_POWER_DISABLED
for (i = 0; i < total; i++) {
if (implementations[i](&retval, seconds, percent)) {
return retval;
}
}
+#endif
/* nothing was definitive. */
*seconds = -1;