Pas2C is an alternative way to build the engine. It is disabled by default.
Pas2C is intended to be used when building the engine natively (e.g. with FreePascal) fails for some reason. However, Pas2C does have some limitations and you should try to first build Hedgewars normally before attempting a Pas2C build.
Pas2C is our hand-written Pascal-to-C-compiler. It works by converting all Pascal code to C, and then compiling the C code with a C compiler. Pas2C itself is written in Haskell. Yes, we're a little crazy. :-)
The Pas2C build currently doesn't support the video recorder. A warning will be printed if you try to build a Pas2C build with video recorder support anyway.
Note! In version 1.0.0, if your
is set to
, building will fail with an error like this:
Preprocessing 'uSound.pas'... pas2c: /builddir/build/BUILD/hedgewars-src-1.0.0/hedgewars/uSound.pas: hGetContents: invalid argument (invalid byte sequence)
This is because Wuzzy accidentally added Unicode characters in the Pascal source code, something which Pas2C doesn't like.
If you have this problem, run this shell script in the root of the source directory before building:
for file in hedgewars/uSound.pas hedgewars/uStats.pas; do
iconv -f utf-8 -t ascii//TRANSLIT $file -o $file.tmp;
mv $file.tmp $file;
This will be fixed in the next version.
and then run
Run from the
ghc -e pas2C \"hwengine\"" pas2c.hs
You can replace "hwengine" with any other module.
Every pas file will be converted to a .c/.h version in the
folder. In case no output is produced something has gone wrong.
compatibility is not yet achieved. We are curious to hear about
(not that we expect anything...)
There are some special files that you need to know:
- contains definitions of external functions defined inside custom pascal units (e.g.
- contains definitions of external functions defined outside our own pascal units (e.g. png and gl units, bundled with FreePascal);
- contains definitions of internal fpc units (provided by the
) which get a
If you need to hide portions of code from Pas2C just wrap it with
To ensure compability with Pas2C, you also must obey the rules stated here: PascalSyntax