[Scummvm-devel] FORBIDDEN_SYMBOL

Max Horn max at quendi.de
Sun Oct 31 22:21:37 CET 2010


Hi there,

as you may have already noticed, I recently added a new header file common/forbidden.h which is included by common/scummsys.h by default.

This header file is meant to help ensure that engines and infrastructure code do not make use of certain "forbidden" APIs, such
as fopen(), setjmp(), etc. This is achieved by re-#defining various symbols to a "garbage" string which then trigers a compiler error. Currently the list of redefined symbols is rather small, but I expect it to grow over time.

Backend files may #define FORBIDDEN_SYMBOL_ALLOW_ALL if they have to access functions like fopen, fread etc. Regular code, esp. code in engines/, should never do that.

I tried to fix all backends for which we do builds on buildbot; but others (e.g. the Symbian port) likely require some additional tweaks. Please look at my recent commits for some examples on how to do that. And also feel free to contact me.


Note that this new header file does *not* flag all instances of abuse. E.g. the Lua code in sword25 is not triggering errors, simply because it does not use common/scummsys.h. Nevertheless, I hope that this header will help us to keep our code portable.
By the way, my primary incentive at this point to create this header is that I would like to get rid of all printf and fprintf calls in our call. The idea is to replace them by a new internal API (say, a "notify()" sibling to warning() & error() ). This would then make it trivial for backends to redirect all console output, or even to "tee" it (print it both on stdout, and into a log file). The latter could then be used by the Windows port to easily implement logging while still showing stuff in a console window.


Bye,
Max



More information about the Scummvm-devel mailing list