Frequently Asked Questions (FAQ) for GNU Pascal on Mac OS X


1.    module/unit interface could not be imported

[G4:~] adriaan% gpc crtdemo.pas
crtdemo.pas:35: module/unit interface `Crt' could not be imported

The solution is to specify --automake

[G4:~] adriaan% gpc --automake crtdemo.pas


2.   gpc: installation problem, cannot exec `as': No such file or directory

G4:~] adriaan% gpc datetimedemo.pas
gpc: installation problem, cannot exec `as': No such file or directory

Mac OS X doesn't come with an assembler and linker installed. What you can do:

1) Install "BSD Subsystem" from the Mac OS X system software CD’s. You need Mac OS X (10.2 or a later version).

2) Install "DevTools.pkg" from the "Developer.mpkg" from the Mac OS X Developer Tools.

The software is on Apple Developer Connection (ADC) Developer CD's and DVD's. If you are not an ADC member, you can join the ADC online program free of charge.

Also, you can download the Apple Mac OS X assembler and linker from the 
GNU Pascal for Mac OS X webpage.


3.   What about frameworks
?

GNU Pascal can link to Mac OS X frameworks. Here is an example:

G4:~] adriaan% gpc --automake -Wl,-framework,Carbon -o SillyBalls SillyBalls.pas


4.    What about compatibility with traditional Macintosh Pascal compilers ?

The GNU Pascal language has many powerful features, but there are a number of compatibility issues
when porting from traditional Macintosh Pascal compilers.



Troubleshooting GNU Pascal on Mac OS X


Debugging

If you experience crashes, enable Crash Reporting in the Preferences dialog of the Console application (found in /Applications/Utilities). This will give you a backtrace of the crash (and also line numbers in source code if compiled with debug information enabled (-g)).

If you need more information, debug your application with gdb.


Stack overflows

If you get "Segmentation fault" it could be a stack overflow. Use the --stack-check option and see if the compiler gives you any warnings. Limit the use of local variables and/or recursion or set the maximum stack size to a larger value:

[G4:~] adriaan% limit
cputime         unlimited
filesize        unlimited
datasize        6144 kbytes
stacksize       512 kbytes
coredumpsize    0 kbytes
memoryuse       unlimited
descriptors     256
memorylocked    unlimited
maxproc         100
[G4:~] adriaan% limit stacksize 2048

To make this the default, type

[G4:~] adriaan% echo "limit stacksize 2048" >> ~/.tcshrc


Non-local goto’s

The gcc-3.3 back-end is still incorrect for non-local goto’s. However, you can work around this with the --longjmp-all-nonlocal-labels compiler option (combined with -O2 instead of -O3).


Can’t emit reloc

If you get a “can’t emit reloc” assembler error, try -O2 instead of -O3.


Known compiler problems

Other known problems in the compiler (not related to Mac OS X) are listed at the GNU Pascal Compiler Project website.


(back to the GNU Pascal for Mac OS X page)