diff --git a/audio/softsynth/mt32.cpp b/audio/softsynth/mt32.cpp index 0b84a5623b2..5371be60b33 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 4d1c612942e..112527cc71b 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 #include #include diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 26df03802c3..6e343b63f55 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 df21d41dda1..4d23a9e0956 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 d5ba6ee1e87..fe86dd20982 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 b3e1138e773..3ae9597f1cb 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 71a88265a0e..889bc5cd5ec 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 #include + OSystem_POSIX::OSystem_POSIX(Common::String baseConfigName) : _baseConfigName(baseConfigName) { diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 4694a061a31..bc27f8e954c 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 diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp index be870abb6ec..37db208223b 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 b74370df4c7..05e1d2c1310 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 7a77d6af7ab..fc4523b8954 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 92e662ccc6b..c22c646b79b 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 - -time - -difftime - -mktime - -localtime - -clock - -gmtime - -system - -remove - -setlocale - -setvbuf +#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 + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_getdate +#undef getdate +#define getdate(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_gmtime +#undef gmtime +#define gmtime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_localtime +#undef localtime +#define localtime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mktime +#undef mktime +#define mktime(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_time +#undef time +#define time(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#endif // FORBIDDEN_SYMBOL_EXCEPTION_time_h + + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_chdir +#undef chdir +#define chdir(a) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +#ifndef FORBIDDEN_SYMBOL_EXCEPTION_mkdir +#undef mkdir +#define mkdir(a,b) FORBIDDEN_SYMBOL_REPLACEMENT +#endif + +/* +#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 6554c701636..46f900b9427 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 7a6e794e11e..e2e1dbdfc73 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 d6f743640b3..8170452102b 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 5192505c795..fb92344de2b 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 5115a1d5b9b..51b46b033cb 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"