diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/forbidden.h | 119 | ||||
-rw-r--r-- | common/scummsys.h | 4 | ||||
-rw-r--r-- | common/xmlparser.cpp | 7 |
3 files changed, 111 insertions, 19 deletions
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" |