mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 23:52:41 +00:00
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
This commit is contained in:
parent
58eebff803
commit
59e77ed667
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -23,6 +23,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
@ -23,6 +23,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Enable mkdir
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
|
||||
|
||||
#include "common/scummsys.h"
|
||||
|
||||
#if defined(UNIX) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -23,6 +23,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// FIXME: Avoid using printf
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_printf
|
||||
|
||||
#include "base/plugins.h"
|
||||
|
||||
#include "engines/advancedDetector.h"
|
||||
|
@ -23,6 +23,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// FIXME: Avoid using printf
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_printf
|
||||
|
||||
#include "base/plugins.h"
|
||||
|
||||
#include "common/archive.h"
|
||||
|
Loading…
Reference in New Issue
Block a user