- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have some code that I'm porting to x64. I have a DLL that in the 32 bit version contains a function label __imp__setversion. Note that there are two underscores before and after the "imp". When I compiled it under the x64 platform, the function seems to be named __imp_setversion, with only a single underscore after "imp". That changes the declaration we need in the source. The 32 bit version needs
!DEC$ ATTRIBUTES DLLIMPORT,ALIAS:'_setversion' :: setversion
While the 64 bit version needs
!DEC$ ATTRIBUTES DLLIMPORT,ALIAS:'setversion' :: setversion
I can't seem to find what is forcing this difference. And I would like to keep the source identical so I would like identical names in the two DLLs.
Any ideas why I'm getting this behavior?
Thanks
Dave
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!DEC$ ATTRIBUTES DLLIMPORT,DECORATE,ALIAS:"setversion" :: setversion
As for "why", that's the way Microsoft defined the naming conventions for x64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay I added the DECORATE attribute (code looks like your sample), but it gives an error:
: Error: Only a function or subroutine subprogram may have the !DEC$ ATTRIBUTES directive DECORATE specifier. [SETVERSION]
I'm not sure what it is looking for now.
I went through the help files. Doesn't seem to mention X64 so it is pretty hard to figure out what is supposed to happen.
Thanks,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
program main
interface
subroutine setversion
!DEC$ ATTRIBUTES DLLIMPORT,DECORATE,ALIAS:"setversion" :: setversion
end subroutine
end interface
call setversion
end
The error message is confusing - I'll ask about that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Now I'm really confused. I have another routine that is decorated the same way yet I get an error that it is looking for __imp__? Here is my interface
interface subroutine setversion( str ) Character *(*)str!DEC$ ATTRIBUTES DLLIMPORT,DECORATE :: setversion
end subroutinesubroutine getVersion( int1,int2 )
Integer int1,int2!DEC$ ATTRIBUTES DLLIMPORT,DECORATE,ALIAS: 'getVersion' :: getVersion
end subroutine end interface
This give the error:
error LNK2019: unresolved external symbol __imp__getVersion referenced in function chklck
But it works fine if I take out the DECORATE. So if DECORATE and ALIAS are used together it appears to add an underscore, but without the ALIAS it doesn't?
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which by the way, makes the example you gave me wrong I believe.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you have ALIAS without DECORATE, the string you give is what is used exactly. No additional decoration is added. When you have ALIAS and DECORATE, the compiler treats what's in ALIAS as a "base", the same as it would for an ordinary routine name, and adds whatever decoration is required for the platform and naming convention in effect.
On 32-bit Windows, with the C convention, that means a leading underscore. On 64-bit Windows, it means no underscore.
I don't know how your DLL routine was built, so I can't comment on what is "right" for you. The example I gave assumes that in the source for "getversion" that no explicit decoration was added to the name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On 32-bit Windows, with the C convention, that means a leading underscore. On 64-bit Windows, it means no underscore.
But this is what I'm saying the compiler says is not correct. On x64 I have ALIAS and DECORATE so for
!DEC$ ATTRIBUTES DLLIMPORT,DECORATE,ALIAS: 'getVersion' :: getVersion
The compiler is looking for __imp__getVersion. It is adding an underscore. While
!DEC$ ATTRIBUTES DLLIMPORT,ALIAS: 'getVersion' :: getVersion Only looks for __imp_getVersion.
So DECORATE seems to behave differently depending on ALIAS (which the strange notes in the manual imply, but isn't clear enough for a dummy like me to make sense of).
I'm building for x64 on 32-bit Windows XP. Is this a problem? Does it really understand what platform it is being built for? Something is wrong between what the compiler is doing and what you say should be happening.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two options for you right now.
1. Remove the DLLIMPORT. Believe it or not, this will work for routines (but not for imported variables). The ALIAS and DECORATE should be specified as I had them.
2. Use this instead:
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES DLLIMPORT, ALIAS : '_setversion' :: setversion
!DEC$ ELSE
!DEC$ ATTRIBUTES DLLIMPORT, ALIAS : 'setversion' :: setversion
!DEC$ ENDIF

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page