vsnprintf and sprintf linker errors

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

I got:

undefined reference to `vsnprintf'

and

undefined reference to `sprintf'

Are these functions missing because I need to add some component?

e.g.:

COMPONENTS += print_func

 

0 Likes
1 Solution
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Hi @BragadeeshV ,  with this change:

//#include <stdio.h>      REMOVED
#include "sparcommon.h"   ADDED

now I get a warning:

../mtb_shared/wiced_btsdk/dev-kit/baselib/20706A2/release-v3.2.0/COMPONENT_20706A2/WICED/common/spar_utils.h:55:17: warning: implicit declaration of function '__2sprintf'; did you mean 'sprintf'? [-Wimplicit-function-declaration]

but the linker error vanished.

So:

1) we don't need stdio.h

2) inside spar_utils.h we get sprintf and snprintf

View solution in original post

4 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @maze_1672671 , Please let us know which SDK, IDE and device you are using.

Regards,
Bragadeesh
0 Likes
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Hello @BragadeeshV , I am using CYW920706WCDEVAL

maze_1672671_0-1644564796156.png

 

maze_1672671_1-1644564819703.png

 

0 Likes
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @maze_1672671 ,

 Support for sprintf and snprintf is present in the ROM code and you have to just include the header stdio.h and use it. vsnprintf does not have inbuilt support in the ROM code and has to be added by linking the C library. However adding support for vsnprintf would cause additional RAM usage than using snprintf. Therefore, wherever possible we highly recommend you to use snprintf over vsnprintf. Please let us know if you still want to enable support for vsnprintf.

Regards,
Bragadeesh
0 Likes
maze_1672671
Level 4
Level 4
First like received 25 replies posted 25 sign-ins

Hi @BragadeeshV ,  with this change:

//#include <stdio.h>      REMOVED
#include "sparcommon.h"   ADDED

now I get a warning:

../mtb_shared/wiced_btsdk/dev-kit/baselib/20706A2/release-v3.2.0/COMPONENT_20706A2/WICED/common/spar_utils.h:55:17: warning: implicit declaration of function '__2sprintf'; did you mean 'sprintf'? [-Wimplicit-function-declaration]

but the linker error vanished.

So:

1) we don't need stdio.h

2) inside spar_utils.h we get sprintf and snprintf