ARM Technical Support Knowledge Articles

What is "warning #223-D: function 'exp2' declared implicitly" and its implication?

Applies to: DS-5, RealView Development Suite (RVDS)

Scenario

In the following example,

#include <math.h>
int main(void)
{
  double d;
  float f;
  long double ld;

  d = exp2(1024.0);
  f = exp2f((float)1024.0);
  ld = exp2l((long double)1024.0);

  printf ("d=%f f=%f ld=%ld\n", d, f, ld);
  return 0;
}

The generated code snippet from "armcc -c -O0 test.c" looks like this:

main
0x00008080: e92d4010 .@-. PUSH {r4,lr}
0x00008084: ed2d8b06 ..-. VPUSH {d8-d10}
0x00008088: ed9f0b10 .... VLDR d0,[pc,#64] ; [0x80d0] = 0x4090000000000000
0x0000808c: eb000274 t... BL exp2 ; 0x8a64
0x00008090: ee000a10 .... VMOV s0,r0
0x00008094: eeb80bc0 .... VCVT.F64.S32 d0,s0
0x00008098: eeb09b40 @... VMOV.F64 d9,d0
0x0000809c: ed9f0b0b .... VLDR d0,[pc,#44] ;
...

exp2
0x00008a64: ec410b10 ..A. VMOV d0,r0,r1
0x00008a68: e92d4010 .@-. PUSH {r4,lr}
0x00008a6c: ebffff0c .... BL __hardfp_exp2 ; 0x86a4
0x00008a70: ec510b10 ..Q. VMOV r0,r1,d0
0x00008a74: e8bd8010 .... POP {r4,pc}

...

As you can see, the caller to exp2() and the function exp2() itself uses different floating point linkage. That is, the ARM registers are passed to VFP D register in exp2(), overriding the D register value passed in the main() function. It appears that the linker selects a wrapper library function (e.g., exp2), which contains software floating point linkage. Therefore the problem exists due to intermixing with different floating point linkage.

Answer

This is not a linker issue. The linker can not simply generate an error message in this example, although the image contain mixed use of FP linkage between function callers and callees. This is because the build attributes cannot be used to generate link time error messages regarding the calling convention. For example, if you are calling a softfp function in a softfp object file from a hardfp object file, there is a build attribute mismatch. But it is perfectly valid to put __softfp in the caller declaration. Then the compiler will generate a softfp compliant function call from the hardfp function. In such circumstance, the linker would be wrong to produce an error in case of a mismatch between the two objects.

In this example, the compiler has no idea what exp2() is, because it is not in the math.h file in C90 mode, hence a warning is produced:

"test.c", line 5: Warning:  #223-D: function "exp2" declared implicitly
      d = exp2(2.0);


The C library functions exp2(), exp2f() and exp2l() are C99 functions. The correct solution to this problem would be to add --c99 in the compiler command line options. This way the compiler is able to generate calls to __hardfp_exp2, __hardfp_exp2f and __hardfp_exp2l, respectively.

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential