Feature request: ignore "#pragma intrinsic"

Feature request: ignore "#pragma intrinsic"

Bild des Benutzers Marián "VooDooMan" Meravý

Greetings,

I use ICC 13 under MSVC 2012.

MSVC 2012 has construct:"#pragma intrinsic(fabs)" before function to let compiler know it should use intrinsic function "fabs" in this case in following function.

ICC doesn't know this #pragma, obviously it has command-line switches to automatically use intrinsic functions when possible. So I need to use following instead before function:

 #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) # pragma intrinsic(fabs) #endif 

It would be cool if ICC would accept "#pragma intrinsic", and instead of raising compile warning would just ignore this pragma.

-- With best regards, VooDooMan - If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.
7 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Bild des Benutzers Marián "VooDooMan" Meravý

Quote:

Marián "VooDooMan" Meravý wrote:


#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)

# pragma intrinsic(fabs)

#endif

It would be cool if ICC would accept "#pragma intrinsic", and instead of raising compile warning would just ignore this pragma.

Just a side note, ICC raises warning "unknown pragma", and I don't want to globally disable this warning, so I need to use above preprocessor guard.

-- With best regards, VooDooMan - If you find my post helpful, please rate it and/or select it as a best answer where applies. Thank you.
Bild des Benutzers Sergey Kostrov

I support Marian's request and I'd like to add that a complete overhaul of different pragmas ( including Intel specific ) is needed because there are Too Many inconsistencies.

Bild des Benutzers Sergey Kostrov

Here are additional technical details.

Last week I completed a test related to using __cdecl, __stdcall and __fastcall calling conventions in the same project (!). It would be nice to have a pragma like,

#pragma function ( FunctionName, calling convention )

An example of usage could look like:

...
#pragma function ( AfxBeginThread, __stdcall );
...

A real problem happens when some project uses MFC function AfxBeginThread and project settings are set as follows:

Project Property Pages -> Configuration Properties -> C/C++ Advanced -> Calling Convention = __fastcall ( /Gr )

Take into account that the AfxBeginThread is declared as follows:

[ Afxwin.h ]
...
// global helpers for threads

CWinThread * AFXAPI AfxBeginThread( AFX_THREADPROC pfnThreadProc, LPVOID pParam,
int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0,
DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );
CWinThread * AFXAPI AfxBeginThread( CRuntimeClass* pThreadClass,
int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0,
DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );
...

[ Afxver_.h ]
...
// AFXAPI is used on global public functions
#ifndef AFXAPI
#define AFXAPI __stdcall
#endif
...

So, there is a conflict between two calling convention specificators, the one which is declared for the function in the header and another one which is set in project settings.

Bild des Benutzers Sergey Kostrov

Even if Intel and Microsoft C++ compilers have similar compilation outputs I think some improvements, or extensions, are needed to resolve all these issues related to usage of __cdecl, __stdcall and __fastcall calling conventions in the same project:

...
Compiling with Intel(R) C++ Compiler XE 12.1.7.371 [IA-32]... (Intel C++ Environment)
IccTestApp.cpp
.\../../Common/PrtTests.cpp(28846): error: no instance of overloaded function "AfxBeginThread" matches the argument list
argument types are: (RTuint (void *), CMyObject *, int, int, int)
pThreadObj[0] = ( CWinThread * )AfxBeginThread( ThreadProc01, pMyObject[0], THREAD_PRIORITY_NORMAL, 1024, CREATE_SUSPENDED );
^

.\../../Common/PrtTests.cpp(28847): error: no instance of overloaded function "AfxBeginThread" matches the argument list
argument types are: (RTuint (void *), CMyObject *, int, int, int)
pThreadObj[1] = AfxBeginThread( ThreadProc02, pMyObject[1], THREAD_PRIORITY_NORMAL, 1024, CREATE_SUSPENDED );
^

.\../../Common/PrtTests.cpp(28848): error: no instance of overloaded function "AfxBeginThread" matches the argument list
argument types are: (RTuint (void *), CMyObject *, int, int, int)
pThreadObj[2] = AfxBeginThread( ThreadProc03, pMyObject[2], THREAD_PRIORITY_NORMAL, 1024, CREATE_SUSPENDED );
^

.\../../Common/PrtTests.cpp(37761): error: argument of type "void (*)()" is incompatible with parameter of type "void (__cdecl *)()"
CrtAtexit( AppExitFunction1 );
^

.\../../Common/PrtTests.cpp(37762): error: argument of type "void (*)()" is incompatible with parameter of type "void (__cdecl *)()"
CrtAtexit( AppExitFunction2 );
^

compilation aborted for .\IccTestApp.cpp (code 2)
IccTestApp - 5 error(s), 0 warning(s), 0 remark(s)
...

Bild des Benutzers Sergey Kostrov

Microsoft C++ compiler output:

...
Compiling...
ScaLibTestApp.cpp
c:\workenv\appsworkdev\common\prttests.cpp(28846) : error C2665: 'AfxBeginThread' : none of the 2 overloads could convert all the argument types
c:\vs.2005\vc\atlmfc\include\afxwin.h(4202): could be 'CWinThread *AfxBeginThread(AFX_THREADPROC,LPVOID,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
c:\vs.2005\vc\atlmfc\include\afxwin.h(4205): or 'CWinThread *AfxBeginThread(CRuntimeClass *,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
while trying to match the argument list '(RTuint (__fastcall *)(void *), CMyObject *, int, int, int)'
c:\workenv\appsworkdev\common\prttests.cpp(28847) : error C2665: 'AfxBeginThread' : none of the 2 overloads could convert all the argument types
c:\vs.2005\vc\atlmfc\include\afxwin.h(4202): could be 'CWinThread *AfxBeginThread(AFX_THREADPROC,LPVOID,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
c:\vs.2005\vc\atlmfc\include\afxwin.h(4205): or 'CWinThread *AfxBeginThread(CRuntimeClass *,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
while trying to match the argument list '(RTuint (__fastcall *)(void *), CMyObject *, int, int, int)'
c:\workenv\appsworkdev\common\prttests.cpp(28848) : error C2665: 'AfxBeginThread' : none of the 2 overloads could convert all the argument types
c:\vs.2005\vc\atlmfc\include\afxwin.h(4202): could be 'CWinThread *AfxBeginThread(AFX_THREADPROC,LPVOID,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
c:\vs.2005\vc\atlmfc\include\afxwin.h(4205): or 'CWinThread *AfxBeginThread(CRuntimeClass *,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)'
while trying to match the argument list '(RTuint (__fastcall *)(void *), CMyObject *, int, int, int)'
c:\workenv\appsworkdev\common\prttests.cpp(37761) : error C2664: 'atexit' : cannot convert parameter 1 from 'void (__fastcall *)(void)' to 'void (__cdecl *)(void)'
None of the functions with this name in scope match the target type
c:\workenv\appsworkdev\common\prttests.cpp(37762) : error C2664: 'atexit' : cannot convert parameter 1 from 'void (__fastcall *)(void)' to 'void (__cdecl *)(void)'
None of the functions with this name in scope match the target type
c:\workenv\appsworkdev\appssca\scalibtestapp\scalibtestapp.cpp(26) : warning C4007: 'wmain' : must be '__cdecl'
ScaLibTestApp - 5 error(s), 1 warning(s)
...

Bild des Benutzers Sergey Kostrov

In overall, three test cases need to be considered:

#pragma function ( AfxBeginThread, __stdcall );
#pragma function ( atexit, __cdecl );
#pragma function ( wmain, __cdecl );

Thanks in advance.

Melden Sie sich an, um einen Kommentar zu hinterlassen.