Combining C and Pascal source. (Was: Const conflict.)
Sat, 26 Apr 1997 15:58:31 +0200 (MET DST)
Frank Heckenbach wrote:
> > > If I compile it with "gpc foo.pas bar.c", it works fine. But if I do
> > > "gpc bar.c foo.pas", it doesn't ("Undefined references" to the C functions).
> > [...]
> I don't think that's the problem. I tried invocing ld manually, and it worked
> whether bar.o was put before or after the Pascal .o's.
> [...]
> So, probably this has got something to do with the left over .gpc file...
1. I cannot reproduce this error. :-( On my system, "gpc foo.pas bar.c"
and "gpc bar.c foo.pas" both work fine - on DJGPP as well as on Linux.
This will be hard to fix.
2. I think I have found the problem: :-) The `gpc' driver program
assumes that the first input file is a Pascal source when doing
`--automake'. I fixed this in `gcc.c'; please retry with the next
Alpha GPC. (A diff for `gcc.c' is appended below.)
Greetings,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
maintainer GNU Pascal [970420] - http://home.pages.de/~gnu-pascal/ [970125]
8< ---------------------------------------------------------------------------
--- gpc-970420/gcc.c Fri Apr 18 12:46:41 1997
+++ gpc/gcc.c Sat Apr 26 10:56:14 1997
@@ -4994,25 +4994,36 @@
obstack_grow (&collect_obstack, "\0", 1);
putenv (obstack_finish (&collect_obstack));
#ifdef GPC
- /* Substitute the basename of the first input file for %b in
- link_command_spec. */
+ /* Substitute the basename of the first Pascal
+ * input file for %b in link_command_spec.
+ */
+ i = 0;
+ while (i < n_infiles
+ && infiles[i].language
+ && strcmp (infiles[i].language, "p") != 0
+ && strcmp (infiles[i].language, "pas") != 0)
+ {fprintf (stderr, "%d\n", i); i++;}
+ if (i < n_infiles)
+ {
+ input_basename = infiles[i].name;
+ for (p = input_basename; *p; p++)
+ if (*p == '/')
+ input_basename = p + 1;
- input_basename = infiles[0].name;
- for (p = input_basename; *p; p++)
- if (*p == '/')
- input_basename = p + 1;
+ /* Find a suffix starting with the last period,
+ * and set basename_length to exclude that suffix.
+ */
+ basename_length = strlen (input_basename);
+ p = input_basename + basename_length;
+ while (p != input_basename && *p != '.')
+ p--;
+ if (*p == '.' && p != input_basename)
+ basename_length = p - input_basename;
- /* Find a suffix starting with the last period,
- and set basename_length to exclude that suffix. */
- basename_length = strlen (input_basename);
- p = input_basename + basename_length;
- while (p != input_basename && *p != '.') --p;
- if (*p == '.' && p != input_basename)
- basename_length = p - input_basename;
-
- explicit_link_files = add_automake_files (explicit_link_files);
+ explicit_link_files = add_automake_files (explicit_link_files);
+ }
#endif /* GPC*/
value = do_spec (link_command_spec);
if (value < 0)
Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es