aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMax Horn2010-10-30 21:27:42 +0000
committerMax Horn2010-10-30 21:27:42 +0000
commit44393b2dc8ba78342dcbb7df39eca2e9e1f6e429 (patch)
treeb5b2d7013d64ca317072453a7fbbc391174e2851 /backends
parentff34a778318355ffba2ee5700524fccba9fe5cf3 (diff)
downloadscummvm-rg350-44393b2dc8ba78342dcbb7df39eca2e9e1f6e429.tar.gz
scummvm-rg350-44393b2dc8ba78342dcbb7df39eca2e9e1f6e429.tar.bz2
scummvm-rg350-44393b2dc8ba78342dcbb7df39eca2e9e1f6e429.zip
ALL: Add code to help stop people from accidentally using "bad" APIs
A new header file common/forbidden.h is included by scummsys.h and it re-#defines numerous symbols like fopen(), fread(), system(), etc. with garbage, in order to provoke compile errors in any code using them. If a .cpp file really *must* use any of these (e.g. because it is a backend file), then these redefinitions can be disabled by #defining FORBIDDEN_SYMBOL_ALLOW_ALL as the first thing in the .cpp file. Whenever this is done, an explanatory comment should be added. Note that this system cannot catch all "bad" usages (notably the Lua code in the sword25 engine), as it can only work if scummsys.h is included. svn-id: r53961
Diffstat (limited to 'backends')
-rw-r--r--backends/fs/stdiostream.cpp3
-rw-r--r--backends/midi/alsa.cpp3
-rw-r--r--backends/midi/camd.cpp3
-rw-r--r--backends/midi/coreaudio.cpp3
-rw-r--r--backends/midi/coremidi.cpp3
-rw-r--r--backends/midi/dmedia.cpp3
-rw-r--r--backends/midi/seq.cpp3
-rw-r--r--backends/midi/stmidi.cpp3
-rw-r--r--backends/midi/timidity.cpp3
-rw-r--r--backends/midi/windows.cpp3
-rw-r--r--backends/platform/sdl/main.cpp2
-rw-r--r--backends/platform/sdl/sdl.cpp5
12 files changed, 36 insertions, 1 deletions
diff --git a/backends/fs/stdiostream.cpp b/backends/fs/stdiostream.cpp
index 8845d796c6..d0600f41a6 100644
--- a/backends/fs/stdiostream.cpp
+++ b/backends/fs/stdiostream.cpp
@@ -23,6 +23,9 @@
*
*/
+// Disable symbol overrides so that we can use FILE, fopen etc.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "backends/fs/stdiostream.h"
StdioStream::StdioStream(void *handle) : _handle(handle) {
diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp
index 4f73d7384b..fd32777a1b 100644
--- a/backends/midi/alsa.cpp
+++ b/backends/midi/alsa.cpp
@@ -22,6 +22,9 @@
* $Id$
*/
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "common/scummsys.h"
#if defined(USE_ALSA)
diff --git a/backends/midi/camd.cpp b/backends/midi/camd.cpp
index 3486532549..7bf702de58 100644
--- a/backends/midi/camd.cpp
+++ b/backends/midi/camd.cpp
@@ -22,6 +22,9 @@
* $Id$
*/
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "common/scummsys.h"
#if defined(__amigaos4__)
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index aa0ad75f0a..97db5cb292 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -24,6 +24,9 @@
#ifdef MACOSX
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
// HACK to disable deprecated warnings under Mac OS X 10.5.
// Apple depracted the AUGraphNewNode & AUGraphGetNodeInfo APIs
// in favor of the new AUGraphAddNode & AUGraphNodeInfo APIs.
diff --git a/backends/midi/coremidi.cpp b/backends/midi/coremidi.cpp
index 08f36a8b0f..bca16df61a 100644
--- a/backends/midi/coremidi.cpp
+++ b/backends/midi/coremidi.cpp
@@ -24,6 +24,9 @@
#ifdef MACOSX
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "common/config-manager.h"
#include "common/util.h"
#include "sound/musicplugin.h"
diff --git a/backends/midi/dmedia.cpp b/backends/midi/dmedia.cpp
index 8c006b2cd9..5e4088fa17 100644
--- a/backends/midi/dmedia.cpp
+++ b/backends/midi/dmedia.cpp
@@ -29,6 +29,9 @@
#if defined(IRIX)
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "common/scummsys.h"
#include "common/util.h"
#include "common/config-manager.h"
diff --git a/backends/midi/seq.cpp b/backends/midi/seq.cpp
index e3d2c35b39..c0098742d0 100644
--- a/backends/midi/seq.cpp
+++ b/backends/midi/seq.cpp
@@ -28,6 +28,9 @@
* both the QuickTime support and (vkeybd http://www.alsa-project.org/~iwai/alsa.html)
*/
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "common/scummsys.h"
#if defined(USE_SEQ_MIDI)
diff --git a/backends/midi/stmidi.cpp b/backends/midi/stmidi.cpp
index b00188dfea..01e28aa5ca 100644
--- a/backends/midi/stmidi.cpp
+++ b/backends/midi/stmidi.cpp
@@ -36,6 +36,9 @@
#if defined __MINT__
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include <osbind.h>
#include "sound/mpu401.h"
#include "common/util.h"
diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp
index 16c1cc43be..d79a83809f 100644
--- a/backends/midi/timidity.cpp
+++ b/backends/midi/timidity.cpp
@@ -34,6 +34,9 @@
*
*/
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "common/scummsys.h"
#if defined(USE_TIMIDITY)
diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp
index 31f057df18..81b29219b4 100644
--- a/backends/midi/windows.cpp
+++ b/backends/midi/windows.cpp
@@ -24,6 +24,9 @@
#if defined(WIN32) && !defined(_WIN32_WCE)
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// winnt.h defines ARRAYSIZE, but we want our own one...
diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp
index 60bf59689c..a9e1f5cf4b 100644
--- a/backends/platform/sdl/main.cpp
+++ b/backends/platform/sdl/main.cpp
@@ -23,6 +23,8 @@
*
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
// Fix for bug #2895217 "MSVC compilation broken with r47595":
// We need to keep this on top of the "common/scummsys.h" include,
// otherwise we will get errors about the windows headers redefining
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 83393c225a..8725a7df8a 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -23,6 +23,9 @@
*
*/
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#if defined(WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@@ -79,7 +82,7 @@
#endif
#if defined(MACOSX) || defined(IPHONE)
-#include "CoreFoundation/CoreFoundation.h"
+#include <CoreFoundation/CoreFoundation.h>
#endif