Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

How to prevent ICC from mangling function names in C code?

augustojd
Beginner
453 Views
Hi all,

When I compile the following source code, it appears that Intel C++ Compiler is mangling "ippsDESBufferSize" regardless of the "/TC" option. __cplusplus is also not defined.

#include "stdio.h"
#include "ippCP.h"

int WinMainCRTStartup() {
int result, size;

result = (int) ippsDESBufferSize(&size);
printf("Result: %d, size: %d ", result, size);
#ifdef __cplusplus
printf("def __cplusplus ");
#endif

return 0;
}

When I try to link the object (compiled with ICC) of this source file with ippCP_XSC41PPC_r.lib in order to generate the executable, I receive this error from the linker:

Compiling...
main.c
Linking...
main.obj : error LNK2001: unresolved external symbol _ippsDESBufferSize@4
ARMV4Rel/tstajd.exe : fatal error LNK1120: 1 unresolved externals

If I use Microsoft eMbedded Visual C++ to compile the source file, the executable is generated without any errors. The same applies to gcc in Linux.

Any ideas of how I can solve this problem?

Environment:
* Microsoft Windows 2000 Professional
* Microsoft eMbedded Visual C++ 4
* PocketPC 2003
* Intel XScale C++ Compiler 1.1
0 Kudos
3 Replies
JenniferJ
Moderator
453 Views
The unresolved symbol _ippsDESBufferSize@4 doesn't look like mangled.
Check the "ippcp.h" to see how this api is defined.
Jennifer
0 Kudos
augustojd
Beginner
453 Views
From ippdefs.h:

#if defined( _WIN32 ) || defined ( _WIN64 )
#define __STDCALL __stdcall
#define __CDECL __cdecl
#define __INT64 __int64
#define __UINT64 unsigned __int64
#else
#define __STDCALL
#define __CDECL
#define __INT64 long long
#define __UINT64 unsigned long long
#endif


#if !defined( IPPAPI )

#if defined( IPP_W32DLL ) && (defined( _WIN32 ) || defined( _WIN64 ))
#if defined( _MSC_VER ) || defined( __ICL )
#define IPPAPI( type,name,arg )
extern __declspec(dllimport) type __STDCALL name arg;
#else
#define IPPAPI( type,name,arg ) extern type __STDCALL name arg;
#endif
#else
#define IPPAPI( type,name,arg ) extern type __STDCALL name arg;
#endif

#endif


Intel C++ Compiler seems to define _WIN32 when compiling code for WinCE on ARM/XScale and therefore all functions are declared as __stdcall. From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_core_adjusting_naming_conventions.asp ,

__cdecl _name Mixed case preserved
__stdcall _name@nn Mixed case preserved

I've dumped the symbols in Intel IPP ippCP_XSC41PPC_r.lib for ARM/XScale and none of them have the __stdcall naming convention, so I suppose they were compiled with __cdecl. Would this be a issue in ippdefs.h (__cdecl should be default for WinCE) or in Intel C++ Compiler (_WIN32 shouldn't be defined for WinCE -- only _W32_WCE should be defined)?
0 Kudos
augustojd
Beginner
453 Views
I've managed to compile and link my code using the following workaround:

#define X _WIN32
#undef _WIN32
#include "ippCP.h"
#define _WIN32 X

If _WIN32 is not defined, IPP's API is __cdecl, which complies to the naming convention in the libraries (.lib). It's still odd, however. =/
0 Kudos
Reply