Hello ,

> 1. In which circumstance will external functions be prefixed by __imp_
> and suffixed by @xxx?

When the function follows the stdcall calling convention.

> 2. Can I have some control over these prefixes and suffixes?
>    I found "extern" keyword removes the __imp_ prefix, but I just couldn't
>    remove @xxx suffix,
>    or I am just wrong

The linker has a --kill-at flag (or something like that) that will remove the @n
from the function names. See the MinGW FAQ; specifically, the section about
DLLs. However, I think that this applies when *you* are building the DLL. I
do not know if this flag can be used to build

> 3. If __imp_ is a convention to indicate external functions imported from a dll,
>  how will @xxx help, and what does the number xxx mean?
>  I believe gcc does not know how linking will happen when compiling source code,
>    thus @xxx suffixes have no use at all

I am inclined to agree with you that the name decoration (mangling) serves no
useful purpose. The number after the @ is the total number of bytes in the
paramater list, so int f(int x, long y) would become f@12, assuming that an int
is 4 bytes, and a long is 8 bytes.

> I may solve my problem when I have some info on these questions, but I think
> it proper to describe my situation:
> I wrote some opengl es code and found it handy to just link them against libEGL
> and libGLESv2 shipped with Firefox. But the linking fails because objects expects
>__imp_* functions while functions in the dlls contains no prefix
> `pexport libEGL.dll` produces:
> LIBRARY libEGL.dll
> eglBindAPI
> eglBindTexImage
> eglChooseConfig
> eglCopyBuffers
> ...
`nm EGLExample.o` produces:
> ...
>        U __imp__eglGetDisplay@4
>        U __imp__eglGetError@0
>        U __imp__eglInitialize@12

What does `nm libEGL.a` say? Are you linking directly to the DLL or are you
using import libraries?

There may be an easier way, but you can create aliases in the .DEF file:

or something similar. Again, I think that the MinGW FAQ will help.

Alias John Brown.