Mail Archives: djgpp/1998/10/20/10:15:27
On Tue, 20 Oct 1998 13:22:14 +0200 (IST), Eli Zaretskii
<eliz AT is DOT elta DOT co DOT il> wrote:
>On Tue, 20 Oct 1998, Primro wrote:
>
>> This raised all sorts of questions in my mind. Firstly, how can I make
>> this single routine in assembly language be part of my C++ library?
>
>Just like any other object file: "ar rvs libfoo.a bar.o".
No- I'm OK with that (thanks to the awesome FAQ)- my problem is that
the functions from the .S file (which are now within this "lib") don't
get found/recognized when I try to link this lib with a .cpp file. But
the functions put in the lib from my .cpp source files get found no
problem.
>> secondly, can't I just use any object files made with DJGPP (from
>> either a cpp or a c file) to make a C++ lib? I seem to get a lot of
>> "no reference to [some function name]" errors in the linking.
>
>You need to declare your assembly function with the ``extern "C"''
>qualifier. There are additional ways to avoid the link errors, but this
>one is the simplest, I think.
Aha! I have it extern, but not extern "C" . That must be it. Thank
you, thank you. I was about to try to inline this thing- yech!
>> If I
>> include <stdio.h> in a C++ file, is this accessing a C lib, or the C++
>> lib?
>
>Neither. A header file such as stdio.h is accessed by a compiler, not
>the linker.
Well, I know I phrased that very badly (reflecting a shaky
understanding of all this)... but what I was really asking was "where
are the functions referenced in the header file coming from." That is,
if I include stdio.h in a C++ file, do the functions I end up adding
to my program come from the gpp lib, or the gcc lib (libc). I assume
the gpp lib.
And beneath that question, basically I am wondering if a C program can
use functions from my C++ lib file, and vice-versa---> or are they
somehow too different.
Thanks, Eli- your quick response means I might make some progress
today.
- Raw text -