[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: converting C to C++ : linkng problems

On Tue, Dec 13, 2005 at 02:31:50PM +0100, Joris Huizer wrote:
> Hello,
> There is this problem: it doesn't link correctly; I get link errors such 
> like this:
> g++   -g -o democomp y.tab.o lex.yy.o debug.o list.o symbol.o syntax.o 
> parser.o intermediate.o register.o flowgraph.o dag.o optimize.o 
> inttomips.o mips.o -lfl
> y.tab.o(.text+0x46a): In function `yyparse()':
> /home/jorishuizer/zooi/coco3-hack/y.tab.cc:1105: undefined reference to 
> `yylex()'
> y.tab.o(.text+0x6dd): In function `yyparse()':
> /home/jorishuizer/zooi/coco3-hack/spascal.y:116: undefined reference to 
> `selectEndOfTable'
> <snip ... lots of these >
> Symbols in two files are not found: those in symbol.cc and those in 
> lex.yy.cc (generated with flex)

Could it be that those files were compiled with C?  C++ oftern doesn't
find C symbols unless they are declared with extern "C".  It can even
be necessary to
  extern "C"{
    #include "a-C-header-file.h"

Could it be that the symbols have subtle data-type incompatibility?
C++ has the habit of mangling names to include data-type information,
so a call to a function using one type (perhaps implicitly determined
in teh absencs of a suitable declaration) doesn't reach a function
of the same name with a different type.

Be careful of the difference between
  void foo();
  void foo(void);
in C.

Reply to: