Since the preprocessor problems have become more urgent with gcc-3.3, the next release of GPC might already contain the new, integrated preprocessor.
Since it will be mostly written from scratch, I don't plan to duplicate obsolete features, in particular C style directives.
To help your conversion if you still use them, I've written the attached script. It requires *GNU* sed and a Unix-compatible shell. (However, the real work is done by sed, so it can probably be easily "ported" to any other shell, perhaps even to Dos command.com if anyone cares.)
GPC supports Pascal directives already for some time, so you can do the conversion now and find out if there are any problems, before you may be forced to do it in a hurry when the next release comes out.
The script it a bit simplistic and may not cover every exotic case, but most normal cases. It's recommended to look at the differences of the changed file and the original to be sure.
In particular, the script does the following conversions:
- One-line: `#foo' to `{$foo}'
- Multi-line:
#define foo(X) \ X \ Y
To:
{$define foo(X) X Y}
- Include files: `#include "foo.pas"' and `#include <foo.pas>' both to `{$include "foo.pas"}'. (There will be no support for `<>' includes anymore since there are no "system headers" in Pascal. If you've relied on the system header directories, it shouldn't take more than an `-I' option to solve it.)
- C operators in conditionals: `&&' to `and', `!' to `not', etc.
- Special cases: `#if 0' to `{$if False}' and `#if 1' to `{$if True}'. This does not replace every 0 and 1 in a conditional since it would be much more complicated to decide if they're used as numbers or Booleans (which is the same in C). Since probably almost all Booleans uses of 0 and 1 in conditionals are of the simple form (otherwise they don't make much sense), this shouldn't cause many problems.
Please report any problems on this list.
Frank