This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: passing float to an external function


Torsten Kühnel writes:
 > Hello,
 > 
 > i have problems passing a simple float value to an external C function.
 > 
 > Passing to a function in the same object file gives the expected
 > results.
 > 
 > But passing it to a function in another object file, which is linked
 > into the executable, it arrives not as it is expected. (at least by me)
 > 
 > 
 > simple sample code-lines, with generated asm listing and some comments: 
 > 
 >  http://vtom.org/externfloatfunc.tgz
 > 
 > 
 > Thank you for any hints. 

Turn on warnings:

 $ gcc -Wall func.c test.c
func.c: In function 'extern_print_float':
func.c:6: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
test.c: In function 'main_print_float':
test.c:9: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
test.c: In function 'main':
test.c:16: warning: format '%d' expects type 'int', but argument 2 has type 'long unsigned int'
test.c:19: warning: implicit declaration of function 'extern_print_float'

You need to fix all of these problems.  In particular, you need to fix
the last one: you must provide a declaration of 'extern_print_float'.

Something like

  extern void extern_print_float(float f);

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]