diff options
author | Max Horn | 2011-05-02 14:42:08 +0200 |
---|---|---|
committer | Max Horn | 2011-05-02 16:31:31 +0200 |
commit | 59e77ed66779d33a14a5f4d2a5885a70b793f36f (patch) | |
tree | 3ca3827f015218ff995faa8be78e21cd631be8ff | |
parent | 58eebff8039bb5cfc9a66bcfadfe078abb94556f (diff) | |
download | scummvm-rg350-59e77ed66779d33a14a5f4d2a5885a70b793f36f.tar.gz scummvm-rg350-59e77ed66779d33a14a5f4d2a5885a70b793f36f.tar.bz2 scummvm-rg350-59e77ed66779d33a14a5f4d2a5885a70b793f36f.zip |
ALL: Mark printf and various other symbols as forbidden
Right now, a few places in the frontend code still use printf and
consorts. We mark the affected files with a FIXME for now, and
add a dedicated exception for each. To be fixed!
Also tweak FORBIDDEN_SYMBOL_REPLACEMENT to hopefully really always
enforce a compiler error
-rw-r--r-- | audio/softsynth/mt32.cpp | 2 | ||||
-rw-r--r-- | audio/softsynth/mt32/synth.cpp | 6 | ||||
-rw-r--r-- | backends/events/sdl/sdl-events.cpp | 2 | ||||
-rw-r--r-- | backends/fs/posix/posix-fs-factory.cpp | 6 | ||||
-rw-r--r-- | backends/graphics/openglsdl/openglsdl-graphics.cpp | 4 | ||||
-rw-r--r-- | backends/graphics/sdl/sdl-graphics.cpp | 4 | ||||
-rw-r--r-- | backends/platform/sdl/posix/posix.cpp | 3 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 3 | ||||
-rw-r--r-- | backends/saves/posix/posix-saves.cpp | 4 | ||||
-rw-r--r-- | base/commandLine.cpp | 3 | ||||
-rw-r--r-- | base/main.cpp | 3 | ||||
-rw-r--r-- | common/forbidden.h | 119 | ||||
-rw-r--r-- | common/scummsys.h | 4 | ||||
-rw-r--r-- | common/xmlparser.cpp | 7 | ||||
-rw-r--r-- | engines/advancedDetector.cpp | 3 | ||||
-rw-r--r-- | engines/agi/detection.cpp | 3 | ||||
-rw-r--r-- | engines/scumm/detection.cpp | 3 |
17 files changed, 154 insertions, 25 deletions
diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index 0b84a5623b..5371be60b3 100644 --- a/audio/softsynth/mt32.cpp +++ b/audio/softsynth/mt32.cpp @@ -351,7 +351,7 @@ void MidiDriver_MT32::send(uint32 b) { void MidiDriver_MT32::setPitchBendRange(byte channel, uint range) { if (range > 24) { - printf("setPitchBendRange() called with range > 24: %d", range); + warning("setPitchBendRange() called with range > 24: %d", range); } byte benderRangeSysex[9]; benderRangeSysex[0] = 0x41; // Roland diff --git a/audio/softsynth/mt32/synth.cpp b/audio/softsynth/mt32/synth.cpp index 4d1c612942..112527cc71 100644 --- a/audio/softsynth/mt32/synth.cpp +++ b/audio/softsynth/mt32/synth.cpp @@ -19,6 +19,12 @@ * IN THE SOFTWARE. */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + +// FIXME: Avoid using vprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_vprintf + #include <math.h> #include <string.h> #include <stdlib.h> diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 26df03802c..6e343b63f5 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -66,7 +66,7 @@ SdlEventSource::SdlEventSource() // Enable joystick if (SDL_NumJoysticks() > 0) { - printf("Using joystick: %s\n", SDL_JoystickName(0)); + debug("Using joystick: %s", SDL_JoystickName(0)); _joystick = SDL_JoystickOpen(joystick_num); } } diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index df21d41dda..4d23a9e095 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -23,6 +23,12 @@ */ #if defined(UNIX) + +// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h. +#define FORBIDDEN_SYMBOL_EXCEPTION_chdir +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_unlink + #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.cpp" diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index d5ba6ee1e8..fe86dd2098 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -488,9 +488,9 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { SDL_RWclose(file); } if (saveScreenshot(filename)) - printf("Saved '%s'\n", filename); + debug("Saved screenshot '%s'", filename); else - printf("Could not save screenshot!\n"); + warning("Could not save screenshot"); return true; } } diff --git a/backends/graphics/sdl/sdl-graphics.cpp b/backends/graphics/sdl/sdl-graphics.cpp index b3e1138e77..3ae9597f1c 100644 --- a/backends/graphics/sdl/sdl-graphics.cpp +++ b/backends/graphics/sdl/sdl-graphics.cpp @@ -2279,9 +2279,9 @@ bool SdlGraphicsManager::notifyEvent(const Common::Event &event) { SDL_RWclose(file); } if (saveScreenshot(filename)) - printf("Saved '%s'\n", filename); + debug("Saved screenshot '%s'", filename); else - printf("Could not save screenshot!\n"); + warning("Could not save screenshot"); return true; } diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 71a88265a0..889bc5cd5e 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -23,6 +23,8 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir + #include "common/scummsys.h" #ifdef UNIX @@ -34,6 +36,7 @@ #include <errno.h> #include <sys/stat.h> + OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName) : _baseConfigName(baseConfigName) { diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 4694a061a3..bc27f8e954 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -23,6 +23,9 @@ * */ +#define FORBIDDEN_SYMBOL_EXCEPTION_time_h + + #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp index be870abb6e..37db208223 100644 --- a/backends/saves/posix/posix-saves.cpp +++ b/backends/saves/posix/posix-saves.cpp @@ -23,6 +23,10 @@ * */ + +// Enable mkdir +#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir + #include "common/scummsys.h" #if defined(UNIX) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) diff --git a/base/commandLine.cpp b/base/commandLine.cpp index b74370df4c..05e1d2c131 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -23,6 +23,9 @@ * */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/metaengine.h" #include "base/commandLine.h" #include "base/plugins.h" diff --git a/base/main.cpp b/base/main.cpp index 7a77d6af7a..fc4523b895 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -31,6 +31,9 @@ * of almost all the classes, methods and variables, and how they interact. */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "engines/engine.h" #include "engines/metaengine.h" #include "base/commandLine.h" diff --git a/common/forbidden.h b/common/forbidden.h index 92e662ccc6..c22c646b79 100644 --- a/common/forbidden.h +++ b/common/forbidden.h @@ -41,18 +41,22 @@ #ifndef FORBIDDEN_SYMBOL_ALLOW_ALL +// Make sure scummsys.h is always included first +#include "common/scummsys.h" + + /** * The garbage string to use as replacement for forbidden symbols. * * The reason for this particular string is the following: - * By including a space and "!" we try to ensure a compiler error. - * By using the words "forbidden symbol" we try to make it a bit - * clearer what is causing the error. + * By including a space and some non-alphanumeric symbols we trigger + * a compiler error. By including the words "forbidden symbol" (which + * the compiler will hopefully print along with its own error message), + * we try to make clear what is causing the error. */ -#define FORBIDDEN_SYMBOL_REPLACEMENT FORBIDDEN SYMBOL! +#define FORBIDDEN_SYMBOL_REPLACEMENT FORBIDDEN SYMBOL !%* -/* #ifndef FORBIDDEN_SYMBOL_EXCEPTION_printf #undef printf #define printf FORBIDDEN_SYMBOL_REPLACEMENT @@ -62,7 +66,16 @@ #undef fprintf #define fprintf FORBIDDEN_SYMBOL_REPLACEMENT #endif -*/ + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_vprintf +#undef vprintf +#define vprintf FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_vfprintf +#undef vfprintf +#define vfprintf FORBIDDEN_SYMBOL_REPLACEMENT +#endif #ifndef FORBIDDEN_SYMBOL_EXCEPTION_FILE #undef FILE @@ -131,30 +144,102 @@ #endif +// Disable various symbols from time.h +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_h + /* -time_t +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time_t +#undef time_t +#define time_t FORBIDDEN_SYMBOL_REPLACEMENT +#endif +*/ + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_asctime +#undef asctime +#define asctime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_clock +#undef clock +#define clock() FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_ctime +#undef ctime +#define ctime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_difftime +#undef difftime +#define difftime(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -time +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getdate +#undef getdate +#define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -difftime +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_gmtime +#undef gmtime +#define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -mktime +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_localtime +#undef localtime +#define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -localtime +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mktime +#undef mktime +#define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -clock +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time +#undef time +#define time(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -gmtime +#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h -system -remove +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_chdir +#undef chdir +#define chdir(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -setlocale +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#undef mkdir +#define mkdir(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif -setvbuf +/* +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setlocale +#undef setlocale +#define setlocale(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif */ +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setvbuf +#undef setvbuf +#define setvbuf(a,b,c,d) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_unlink +#undef unlink +#define unlink(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +/* + * We also would like to disable the following symbols; + * however, these are also frequently used in regular code, + * e.g. for method names, so we don't override them. + * - read + * - remove + * - write + * - ... + */ + + #endif diff --git a/common/scummsys.h b/common/scummsys.h index 6554c70163..46f900b942 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -367,7 +367,7 @@ #if defined(__GNUC__) #define NORETURN_POST __attribute__((__noreturn__)) #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y))) + #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) #if !defined(FORCEINLINE) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) #define FORCEINLINE inline __attribute__((__always_inline__)) @@ -375,7 +375,7 @@ #elif defined(__INTEL_COMPILER) #define NORETURN_POST __attribute__((__noreturn__)) #define PACKED_STRUCT __attribute__((__packed__)) - #define GCC_PRINTF(x,y) __attribute__((__format__(printf, x, y))) + #define GCC_PRINTF(x,y) __attribute__((__format__(__printf__, x, y))) #else #define PACKED_STRUCT #define GCC_PRINTF(x,y) diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp index 7a6e794e11..e2e1dbdfc7 100644 --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -23,6 +23,13 @@ * */ +// FIXME: Avoid using fprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_fprintf + +// FIXME: Avoid using vfprintf +#define FORBIDDEN_SYMBOL_EXCEPTION_vfprintf + + #include "common/xmlparser.h" #include "common/archive.h" #include "common/fs.h" diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index d6f743640b..8170452102 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -23,6 +23,9 @@ * */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "common/debug.h" #include "common/util.h" #include "common/hash-str.h" diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 5192505c79..fb92344de2 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -23,6 +23,9 @@ * */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "base/plugins.h" #include "engines/advancedDetector.h" diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 5115a1d5b9..51b46b033c 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -23,6 +23,9 @@ * */ +// FIXME: Avoid using printf +#define FORBIDDEN_SYMBOL_EXCEPTION_printf + #include "base/plugins.h" #include "common/archive.h" |