Compiler error "undefined identifier 'sprintf' "

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

Compiler error "undefined identifier 'sprintf' "

Jump to solution
3,594 Views
rmbvector
Contributor I

i'm using CW for MobileGT V9.2 and using the command_line_tools to build with. I've built a similar project for C and sprintf gets resolved there just fine and i can see from the .map file that it is defined in in the following lib.a

sprintf     MSL_C.PPCEABI.bare.H.UC.a printf.o

 

I assume that i'm not including the right library somehow for the C++ environment i'm trying to build. i would have thought that defining the following would get sprintf resolved

 

set MWLibraryFiles=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C\PPC_EABI\Lib\MSL_C.PPCEABI.bare.H.UC.a;%MWLibraryFiles%

 

the compile command is

 

mwcceppc -gdwarf2 -C -proc e300c1  -lang c++  -RTTI on -D_MSL_CONSOLE_SUPPORT -DVCAST_NO_FLOAT -DVCAST_DO_NOT_INCLUDE_STDIO -DVCAST_MAX_STRING_LENGTH=130 -DVCAST_STDIO -DVCAST_CLASS_INST_SHARING -DVCAST_DISABLE_STD_STRING_DETECTION -DVCAST_DISABLE_STD_WSTRING_DETECTION -DVCAST_NO_LIMITS -DVCAST_NO_SETJMP -DVCAST_NO_STDIN -DVCAST_NO_STDLIB -DVCAST_SBF_UNITS_AVAILABLE -DVCAST_CPP_ENVIRONMENT -DVCAST_ORIGINAL_CODE -DVECTORCAST   -IC:\cygwin\home\rmb\vector\build\17024_cwppc_hg\vc\DATA\codewarrior\EPPC -I"c:\\Program Files\\Freescale\\CodeWarrior for MobileGT V9.2\\powerpc_eabi_support\\Runtime\\Include" -IC:\PROGRA~1\FREESC~1\CODEWA~3.2\PowerPC_EABI_Support\Runtime\Include -I"c:\\Program Files\\Freescale\\CodeWarrior for MobileGT V9.2\\powerpc_eabi_support\\Runtime\\Lib" -IC:\PROGRA~1\FREESC~1\CODEWA~3.2\PowerPC_EABI_Support\Runtime\Lib -IC:\VECTOR\win32.52d\Tutorial\cpp   B0000002.cpp

 

the error i get is

 

### mwcceppc Compiler:
#    File: B0000002.cpp
# ---------------------
#    1159:      VCAST_sprintf (VC_S,VCAST_PRINTF_DECIMAL_LONG_DOUBLE,VC_F);
#   Error:                                                               ^
#   undefined identifier 'sprintf'
### mwcceppc Compiler:
#    2548:   VCAST_sprintf (VC_FILENAME,"E%.7d.DAT", vCAST_CURRENT_SLOT+1);
#   Error:                                                               ^
#   undefined identifier 'sprintf'

 Here is my complete environment variables setup

 

 

set CWFolder=C:\PROGRA~1\FREESC~1\CODEWA~3.2  

set PATH=%CWFolder%\PowerPC_EABI_Tools\Command_Line_Tools;%PATH%
set path=%CWFolder%\bin;%PATH%

 

set MWCIncludes=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C\PPC_EABI\Include;
set MWCIncludes=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C\MSL_Common\Include;%MWCIncludes%
set MWCIncludes=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C\MSL_Common_Embedded\Include;%MWCIncludes%
set MWCIncludes=%CWFolder%\PowerPC_EABI_Support\Runtime\Include;%MWCIncludes%
set MWCIncludes=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C\MSL_Common\Src;%MWCIncludes%
set MWCIncludes=%CWFolder%\PowerPC_EABI_Support\SystemCallSupport\Src;%MWCIncludes%

set MWLibraries=%CWFolder%\PowerPC_EABI_Support\Runtime\Lib;%MWLibraries%
set MWLibraries=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C++\PPC_EABI\Lib;%MWLibraries%
set MWLibraries=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C\PPC_EABI\Lib;%MWLibraries%
set MWLibraries=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C++\MSL_Common\Src;%MWLibraries%
set MWLibraries=%CWFolder%\PowerPC_EABI_Support\SystemCallSupport\Src;%MWLibraries%

set MWLibraryFiles=%CWFolder%\PowerPC_EABI_Support\Runtime\Lib\Runtime.PPCEABI.H.UC.a
set MWLibraryFiles=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C++\PPC_EABI\Lib\MSL_C++.PPCEABI.bare.H.UC.a;%MWLibraryFiles%
set MWLibraryFiles=%CWFolder%\PowerPC_EABI_Support\MSL\MSL_C\PPC_EABI\Lib\MSL_C.PPCEABI.bare.H.UC.a;%MWLibraryFiles%
set MWLibraryFiles=%CWFolder%\PowerPC_EABI_Support\SystemCallSupport\Lib\syscall.a;%MWLibraryFiles%

 

 

thanks for any advice

Rob

Labels (1)
0 Kudos
1 Solution
1,877 Views
CrasyCat
Specialist III

Hello

 

 Did you include stdio.h in the file B0000002.cpp?

 

Also you seem to be using a lot of macros. Did you take a look at the preprocessor listing file to make sure all the macros are expanded as you expect?

 

CrasyCat

View solution in original post

0 Kudos
3 Replies
1,878 Views
CrasyCat
Specialist III

Hello

 

 Did you include stdio.h in the file B0000002.cpp?

 

Also you seem to be using a lot of macros. Did you take a look at the preprocessor listing file to make sure all the macros are expanded as you expect?

 

CrasyCat

0 Kudos
1,877 Views
rmbvector
Contributor I

 

i was  including <cstdio> but apparently that doesn't work and including <stdio.h> as you suggested did cause sprintf to get resolved.  the freescale docs claim that the C++ implementation of std lib functions like sprintf are contsined in <cstdio> ?? hmmm? missing something there i guess. thanks for the help.

 

Also when i tried to examine the preprocessor output i was getting a preprocessor error

 

      #error directive: mslGlobals.h could not include prefix file
          #error mslGlobals.h could not include prefix file

 

which makes me think there is a missing platform predefined symbol (e.g. __POWERPC__) that would perhaps get defined in the IDE via some check/edit box, that i should be defining for use with our command line tools build.  any idea where that processor define happens so i can mimic the same with a command line #define?

 

 

thanks again for your help

Rob

 

 

0 Kudos
1,877 Views
CrasyCat
Specialist III

Hello

 

I do not have a MobileGT installation on my Host PC right now, so I cannot check how this is looking like.

 

As far as I remember there is a location in the target settings dialog, where you can specify a prefix file.

If you create a project fusing the wizard the appropriate prefix file should be specified. All the prefix files are name ansi_prefix*.h.

 

If you are building from command line there is a corresponding option -prefix.

 

CrasyCat

0 Kudos