How can I suppress the compiler warning: multiply-defined: 'printf'  in libc_E200z760_VLE_SPFP_Only.a in the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o Previously defined in printf.obj

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I suppress the compiler warning: multiply-defined: 'printf'  in libc_E200z760_VLE_SPFP_Only.a in the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o Previously defined in printf.obj

Jump to solution
1,988 Views
thomasl1
Contributor I

How can I suppress the following compiler warnings when I already have user defined functions for printf() and sprintf():

multiply-defined: 'printf'  in libc_E200z760_VLE_SPFP_Only.a in the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o Previously defined in printf.obj ignored: 'printf'  in libc_E200z760_VLE_SPFP_Only.a from the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o

 

multiply-defined: 'sprintf'  in libc_E200z760_VLE_SPFP_Only.a in the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o Previously defined in printf.obj ignored: 'sprintf'  in libc_E200z760_VLE_SPFP_Only.a from the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o

Description Resource Path Location Typemultiply-defined: 'printf'  in libc_E200z760_VLE_SPFP_Only.a in the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o Previously defined in printf.obj ignored: 'printf'  in libc_E200z760_VLE_SPFP_Only.a from the file D:\workspace\EPPC\workspace_codegen\ewl\EWL_C\EWL_C.PA_CmdLineData\libc_E200z7 60_VLE_SPFP_Only\obj\printf.o PCM C/C++ Problem

Labels (1)
0 Kudos
1 Solution
1,648 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello LV

 

User can use  <#pragma suppress_warnings off> to disable the warning message.   And can also use the  <#pragma warning off (num [, ...]) > to disable a specific warning message.  ( To get to know the warning number, please use the <#pragma showmessagenumber> to display warning messages with their warning numbers.)

However, I do not think this is good solution for this problem of multiply-defination.

 

The functions 'printf' and 'sprintf'  are contained in MSL C library libc_E200z760_VLE_SPFP_Only.a. You should have already included this lib in your project.  When user defines the user functions with the same name, linker will prompt such message.

So it is better to rename your user functions to avoid such conflict.

Or you can just ignore this warning, because by default, the the linker always processes source code files before it processes relocatable ( .o ) files or archive ( .a ) files. This policy means that the linker prefers using a symbol definition from a source file rather than a library file definition for the same symbol.

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
1,649 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello LV

 

User can use  <#pragma suppress_warnings off> to disable the warning message.   And can also use the  <#pragma warning off (num [, ...]) > to disable a specific warning message.  ( To get to know the warning number, please use the <#pragma showmessagenumber> to display warning messages with their warning numbers.)

However, I do not think this is good solution for this problem of multiply-defination.

 

The functions 'printf' and 'sprintf'  are contained in MSL C library libc_E200z760_VLE_SPFP_Only.a. You should have already included this lib in your project.  When user defines the user functions with the same name, linker will prompt such message.

So it is better to rename your user functions to avoid such conflict.

Or you can just ignore this warning, because by default, the the linker always processes source code files before it processes relocatable ( .o ) files or archive ( .a ) files. This policy means that the linker prefers using a symbol definition from a source file rather than a library file definition for the same symbol.

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

1,648 Views
thomasl1
Contributor I

Fiona,

Thanks for the input and info of #pragma use below to show and suppress the warnings.  I can now switch the warnings on, off, or suppress them as needed per source code file.

#pragma showmessagenumber on

#pragma warning off (number)

#pragma suppress_warnings on

LV Thomas

0 Kudos
1,648 Views
kef2
Senior Contributor IV

Having the same problem in the past with CW for S12(X), IIRC warning happens when single CW lib source module provides several functions and you are providing your own functions not for all of these functions. Say lib file contains src.o, which was made compiling src.c and defines foo1(), foo2() and foo3(). If you define your own foo1(), and keep using foo2() or foo3() from CW library, then you will get this warning about ignoring one or mode functions. If your code defines just foo1() and doesn't use foo2() and foo3(), you should not see that warning.