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
So, my question is: where does gpc expect to find the c code? Or, a different angle on the same issue: how do I tell it where to find the c code? Thanks
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
Frank Heckenbach wrote:
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
-- Frank Heckenbach, f.heckenbach@fh-soft.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8
Thanks for the quick reply. --unit-path worked.
For those searching the forum who have the same problem, the full comand line was: gpc --automake --unit-path=/home/hb/pas cnp.pas -o cnp
(Yes, I agree that the full pathname is bad programming practice, I added it just on the off chance that it might convey some information to anyone trying to help me.)
...Which GPC and GCC versions and which system do you use? How do you
invoke it...? I'm using Fedora 3. I invoke gpc with: gpc cnp.pas -o cnp When invoked with the v flag, gpc prints - among lots of other stufff - the following 2 lines: GNU Pascal version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled by GNU C version 3.3.3 GNU Pascal version is actually 2.1 (20020510), based on gcc-2.95.2 19991024 (release)
Harmonious Botch wrote:
...Which GPC and GCC versions and which system do you use? How do you
invoke it...? I'm using Fedora 3. I invoke gpc with: gpc cnp.pas -o cnp When invoked with the v flag, gpc prints - among lots of other stufff - the following 2 lines: GNU Pascal version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled by GNU C version 3.3.3 GNU Pascal version is actually 2.1 (20020510), based on gcc-2.95.2 19991024 (release)
I see, this version is from 2002 (2002-05-10) and might have had a bug in "{$L}" (I don't remember exactly). If this version works for you, fine, but if you encounter other bugs (and there were quite a few which have been fixed meanwhile), you might want to upgrade, even if the newer versions are labeled alpha/beta.
Frank