views:

270

answers:

3

hello, I'm trying to port a Windows app to Linux. This appplication marks some functions with the __stdcall attribute. However, i was told by a friend that stdcall is used only on windows and has no meaning in linux (but DOES exist in Windows GCC). I tried to search Google about that, and got some results state that there IS stdacll in Linux.

So... ??

Besides, for GCC I saw 2 implementations for that: __attribute__((__stdcall__)) and __attribute__((stdcall)) (without the underscores near stdcall). Which one is preferred (If applied to Linux at all)?

Thanks!

A: 

AFAIK, it doesn't apply to Linux at all.

Jerry Coffin
According to this link - it appears...http://www.programmersheaven.com/2/Calling-conventions#stdcall
Break Point
+1  A: 

The simplest solution is to just define __stdcall to nothing conditionally on Linux.

dicroce
It doesn't compile with GCC.
Break Point
Thats why I suggested writing a conditional (linux only) macro that expands to "".
dicroce
+3  A: 

Here's a link to __stdcall description on MSDN: http://msdn.microsoft.com/en-us/library/zxk0tw93(VS.80).aspx

It's only used to call WinAPI functions. To port such a Windows application to Linux, you need much more than just defining __stdcall to nothing:

#ifndef WIN32 // or something like that...
#define __stdcall
#endif

You would also need to call the Linux-specific API functions instead of Win32 API ones. Depending on the particular part of Win32 API and the size of the application (amount of code), it can be anywhere between moderately difficult and daunting.

Which specific functions are marked by the app as __stdcall?

Indeed, Windows port of GCC has to have __stdcall, because it's supposed to be able to generate conforming code for the Win32 platform. But since under Linux there is only one standard calling convention and it coincides with the default compiler output, this statement is not needed.

The reason your application is not compiling under Linux is almost certainly due to the fact, that it references Win32 API functions that are not defined under Linux -- you need to find appropriate Linux counterparts. Win32 API and Linux GLibc API-s are very much different and cannot be substituted easily.

Probably the easiest way to port your app to Linux would be to use Wine, i.e. modifying the Windows code in such a way, that it runs smoothly under Wine in Linux. This is the way even the most complex applications, like modern computer games, have been made to run under Linux.

Of course, if you really want it to be running natively under Linux, then porting is the only way to go.

deemoowoor