Short form of the question:
When I build the same program, same compiler (g++2.6.3), same
prototypes on an SGI/Irix5.2, it links. On the Alpha, I get:
Unresolved:
free__FPv
malloc__FUl
realloc__FPvUl
calloc__FUlUl
from the loader. Inspection with ld -y shows that the object files generated
on the SGI refer to 'free', those on the Alpha refer to 'free__FPv'. There
were no prototypes for these routines on the Alpha, so I put my own in,
as mentioned below.
Long form of question with gory details:
Okay, I'm a little perplexed. First, background:
OSF 3.0, gcc/g++ 2.6.3, libg++ 2.6.2.
Now I'm trying to build some C++ code with g++. I have two files which
require malloc and friends; when I #include </usr/include/malloc.h> in them,
I get:
195 jonh_at_stout/alpha> make
g++ -pedantic -c chunk.cxx
chunk.cxx: In method `GSchunk::~GSchunk()':
chunk.cxx:21: warning: implicit declaration of function `int free(...)'
chunk.cxx: In method `enum GSErr GSchunk::installChunk(class GSgroupManager *)':
chunk.cxx:35: warning: implicit declaration of function `int malloc(...)'
chunk.cxx:35: warning: assignment to `void *' from `int' lacks a cast
g++ -pedantic -c list.cxx
list.cxx: In method `GSlist::~GSlist()':
list.cxx:18: warning: implicit declaration of function `int free(...)'
list.cxx: In method `int GSlist::insertItem(class GSlistMember *)':
list.cxx:28: warning: implicit declaration of function `int realloc(...)'
list.cxx:31: warning: implicit declaration of function `int calloc(...)'
g++ -pedantic -o try try.o chunkManager.o groupManager.o chunk.o chunkRef.o list.o listMember.o ipcAgent.o chunkIDHash.o gsErr.o GROUPchunk.o
And it compiles, but with heinous errors. Why aren't malloc() and friends
prototyped in the standard include files?
Furthermore, when I write my own prototypes and recompile with my own local
"malloc.h":
#include <stdio.h>
void *malloc(size_t size);
void *calloc(size_t num_of_elts, size_t elt_size);
void *realloc(void *pointer, size_t size);
void free(void *pointer);
/* I've also tried this with 'extern' in front of each line */
I get:
g++ -pedantic -c chunk.cxx
g++ -pedantic -c list.cxx
g++ -pedantic -o try try.o chunkManager.o groupManager.o chunk.o chunkRef.o list.o listMember.o ipcAgent.o chunkIDHash.o gsErr.o GROUPchunk.o
/bin/ld:
Unresolved:
free__FPv
malloc__FUl
realloc__FPvUl
calloc__FUlUl
collect2: ld returned 1 exit status
*** Exit 1
Stop.
It appears my prototypes got whunked into the C++ naming conventions, so that
they wouldn't link with the symbols named in the standard libraries.
My questions:
1. Why doesn't OSF/1 prototype malloc() and friends? I did a find -exec
grep, and nothing under /usr/include appeared to prototype malloc().
2. How do I find out more about C++ symbol-munging? I'd like to know
the hows and whys, and how I can say in a prototype that this is a
boring old C function, so don't munge the symbol name.
Thanks many,
--Jon
P.S. disclaimer: This looks a lot like a post to comp.unix.osf.osf1,
but I waited a while there and didn't get a reply, and I'm in a bit of
a pinch to get this going. I hope it's not out of line for the list. I
checked the osf-mgrs list archive and the osf1-ultrix common faq before
posting either note.
Jon Howell 206-616-1478 voice
Systems Administrator 206-543-5380 fax
Human Interface Technology Lab. jonh_at_hitl.washington.edu
University of Washington, FJ-15
Seattle, Washington 98195
Received on Wed Apr 19 1995 - 15:20:49 NZST