Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28954 Discussions

Linker: error: incompatible calling convention declarations for routine ?

MikeWinsteps
Novice
1,905 Views

Folks, compiling with IFORT 2021.9 under Windows with VS 17.5.

I have about 50 "DialogBoxParam" call-back functions, all with the same interface, etc. They compile correctly, but the Linker complains about two:

 

"": error: incompatible calling convention declarations for routine mrwe_arrows

the Linker puts this message in the Error List 3 times, though the routine is called about 50 times.

 

"": error: incompatible calling convention declarations for routine mrwe_pifile

the Linker puts this message in the Error List 6 times, though the routine is called 2 times.

 

Any suggestions about what is going on?

 

 

 

 

Labels (1)
0 Kudos
9 Replies
andrew_4619
Honored Contributor III
1,869 Views

Yes the callbacks need to be stdcall convention. The interface I use look like:

    INTERFACE
       FUNCTION DialogBoxParam( hInstance, lpTemplateName, hWndParent, lpDialogFunc, dwInitParam) BIND(C,NAME="DialogBoxParamA")
          import
          integer(INT_PTR) :: DialogBoxParam ! INT_PTR
          !DIR$ ATTRIBUTES STDCALL :: DialogBoxParam
          !GCC$ ATTRIBUTES STDCALL :: DialogBoxParam
          integer(HANDLE), value :: hInstance ! HINSTANCE hInstance
          integer(LPVOID), value :: lpTemplateName ! LPCSTR lpTemplateName
          integer(HANDLE), value :: hWndParent ! HWND hWndParent
          integer(LPVOID), value :: lpDialogFunc ! DLGPROC lpDialogFunc
          integer(LONG_PTR), value :: dwInitParam ! LPARAM dwInitParam
       END FUNCTION
    END INTERFACE

 The !GCC$ line is for gfortran..... If you are using module IFWIN the implementation may look a little different I did not check.

0 Kudos
MikeWinsteps
Novice
1,844 Views

Thanks, Andrew. The solution was simple: rewrite the code so that each of those two functions was only called from one place. It seems that the Linker detected differences between the multiple calls to each function that were invisible to me. 

0 Kudos
andrew_4619
Honored Contributor III
1,578 Views

bizarre, maybe I should open a new thread. Today I get exactly the same error (3 times),  the error is not given with a debug build but is with a release build.  The call back is in a module, it has an explicit interface. It has worked OK yesterday (and for a long time before that also).  And it seems to create a functional exe despite the error message. Any ideas? I am suspecting a problem in the compiler making duff input for the linker.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,414 Views

>>It has worked OK yesterday

You may have a build dependency order issue. Try a Rebuild Build All

A related issue is when the configuration is missing a Build check box check in the Configuration Manager for the specific Configuration and Platform.

 

Also, what happens when you change the last argument type to LPVOID?

 

Jim Dempsey

 

0 Kudos
andrew_4619
Honored Contributor III
1,535 Views

I get the error in Ifort in release  but all other ifort/ifc/release/debug combination do not get the error.

Linking...
"": error: incompatible calling convention declarations for routine ViewsDlgProc

"": error: incompatible calling convention declarations for routine ViewsDlgProc

"": error: incompatible calling convention declarations for routine ViewsDlgProc
Embedding manifest...

Further I have other stdcall callbacks with exactly the same usage case that work just fine.

0 Kudos
andrew_4619
Honored Contributor III
1,425 Views

Did anyone at Intel look at this , note that the error message is malformed with "" as the start suggesting something is missing.

0 Kudos
Barbara_P_Intel
Employee
1,414 Views

@andrew_4619, do you have a reproducer? You knew I'd ask, didn't you? 

0 Kudos
JohnNichols
Valued Contributor III
1,367 Views

@Barbara_P_Intel ,

 

Thank you for the smile in my mind in the morning,  there are three great statements in life:

1. Let there be light ------------ and Fortran was born

2. What is the meaning of life, the number after the 13th prime, although 1 is a prime, I will talk to God about this mistake in the end.  Of course, @mecej4 , can explain why I am wrong.  I read part of Wiles proof of the Fermat's Last Theorem, Wiles is not a normal human bean. 

3. Do you have a reproducer ---    I will not comment as it is just two beautiful for words.  (Two is not a mistake)

4. Dad you are a loser --- from my last daughter on being angry with something I said. 

You may all decide the incorrect answer. 

0 Kudos
andrew_4619
Honored Contributor III
1,384 Views

I can't submit the whole project as a reproducer, I will attempt to create one however I have a concern that is may be difficult as there are other call back routines in the code with the same interface/attributes that cause no issues. 

0 Kudos
Reply