Harmonious Botch wrote:
I'm writing a rather simple program to include c code in gnu pascal. When the compiler encounters the following line of pascal code:
{$L cnp.c}
it generates the following error:
file `cnp.c' not found
Yet the c source code and the pascal source code are in the same directory. I tried working around this by using the full file descriptor, like this:
{$L /home/hb/pas/cnp.c }
but gpc removes the forward slashes, and gives me this error message:
file `homehbpascnp.c' not found
I can't reproduce this behaviour. Which GPC and GCC versions and which system do you use? How do you invoke it (--automake, gp, ...)?
But even if it worked, it's really not recommended to do so, as it would tie it to a particular directory location, i.e. you'd need to change the source code in order to compile it in another directory. That's generally bad style, and will only make distribution, testing, debugging etc. more difficult.
So, my question is: where does gpc expect to find the c code?
By default in the current directory (i.e., not necessarily the directory of the Pascal source), and the default unit directories (but they're meant only for C code for units that come with GPC).
Or, a different angle on the same issue: how do I tell it where to find the c code?
With --unit-path or --object-path. The former applies to Pascal units and C code (and assembler code, object files ...), the latter only to C code etc. (I usually use --unit-path only, and put my units and corresponding C code in the same directories.)
Frank