Unresolveable fallthrough functions

Hello,

> ERROR: Program used external function 'putchard' which could not be
resolved!
Any idea of what could be wrong?

Please make sure you're using C linkage for such functions, due to mangling the name of
function being emitted is not "putchard". Something like this:

extern "C" void putchard(char c) {
...
}

Or, just provide a mapping by hands (if you're on platform without dynamic linking, e.g. on
windows)

Anton Korobeynikov wrote:

Hello,

> ERROR: Program used external function 'putchard' which could not
be
resolved!
Any idea of what could be wrong?

Please make sure you're using C linkage for such functions, due to
mangling the name of
function being emitted is not "putchard". Something like this:

extern "C" void putchard(char c) {
...
}

Or, just provide a mapping by hands (if you're on platform without dynamic
linking, e.g. on
windows)

Thanks for the reply. I'm on Linux and the function is extern'd:

extern "C" double putchard(double X) {
  putchar((char)X);
  return 0;
}

Using the sin(x) and cos(x) functions work though, only the ones included in
the main file don't. So I'm a bit puzzled...

Thanks,
Matthieu

-----Message d'origine-----
De : llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu]
De la part de mriou
Envoyé : lundi 1 septembre 2008 20:18
À : llvmdev@cs.uiuc.edu
Objet : Re: [LLVMdev] Unresolveable fallthrough functions

Anton Korobeynikov wrote:
>
> Hello,
>
>> > ERROR: Program used external function 'putchard' which could
not
>> be
>> resolved!
>> Any idea of what could be wrong?
> Please make sure you're using C linkage for such functions, due to
> mangling the name of
> function being emitted is not "putchard". Something like this:
>
> extern "C" void putchard(char c) {
> ...
> }
>
> Or, just provide a mapping by hands (if you're on platform without
dynamic
> linking, e.g. on
> windows)
>

Thanks for the reply. I'm on Linux and the function is extern'd:

extern "C" double putchard(double X) {
  putchar((char)X);
  return 0;
}

Using the sin(x) and cos(x) functions work though, only the ones
included in
the main file don't. So I'm a bit puzzled...

Thanks,
Matthieu

If you don't use the function anywhere, the compiler may/will strip it off
(or if the compiler can 'understand' that the function is never called). It
may be the problem.

Just my 2cents

Cédric

mriou wrote:

Using the sin(x) and cos(x) functions work though, only the ones included in
the main file don't. So I'm a bit puzzled...

Did you link your executable with -rdynamic?

Ah yes you’re right (as well as Cedric). Using -rdynamic solved it, thanks a lot for the help. I’ll submit a documentation patch for the tutorial.

Thanks!
Matthieu