This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Dll entry point aliasing
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: John Barnes <johnbarnes2858 at gmail dot com>
- Cc: Fortran List <fortran at gcc dot gnu dot org>
- Date: Sun, 22 Jun 2014 19:05:15 +0300
- Subject: Re: Dll entry point aliasing
- Authentication-results: sourceware.org; auth=none
- References: <CAPEbvBW4E6byMSxFeSAL8gr7k0AKKsVrx4diQdUAADzrmt9cwQ at mail dot gmail dot com>
On Sun, Jun 22, 2014 at 5:49 PM, John Barnes <johnbarnes2858@gmail.com> wrote:
> I have a FORTRAN dll that I have compiled and used in a couple of
> FORTRAN dialects. Seems that gFORTRAN (used in the MinGW32 environment
> on Windows 7) sees the entry points a little differently.
>
> This is how one of the entry points is defined in the FORTRAN code:
>
> subroutine XXXX_ENGINE_INITIALISE(args, success_code)
> !DEC$ ATTRIBUTES DLLEXPORT :: XXXX_ENGINE_INITIALISE
> !DEC$ ATTRIBUTES ALIAS:'_XXXX_ENGINE_INITIALISE' ::
> XXXX_ENGINE_INITIALISE
> character(*), intent(in) :: args
> integer, intent(out) :: success_code ! 0: ok, -ive fatal error, +ive warning
>
> The above is used with C# calling code like:
>
> [DllImport(ExternalDll_C.Filename,
> EntryPoint = "XXXX_ENGINE_INITIALISE",
> ExactSpelling = false,
> CallingConvention = CallingConvention.Cdecl)
> ]
> internal static extern void XXXX_ENGINE_INITIALISE(
> [MarshalAs(UnmanagedType.LPStr)] StringBuilder inString,
> ref int successCode, // 0: ok, -ive fatal error, +ive warning
> int inStringLength);
>
> Compile the above with other dialects of FORTRAN I have available and
> Dependency Walker shows the dll has the expected entry point
> XXXX_ENGINE_INITIALISE.
>
> Compile using gFORTRAN and the entry point comes out as:
>
> xxxx_engine_initialise_
>
> I suspect that gFORTRAN does not recognise the DEC$ comment directives
> and just applies its own name mangling. Is there a way I can change
> that? Ideally with some other comment directive?
Indeed, GFortran does not recognize DEC$ directives. GFortran has its
own (similar) attribute syntax, see Section 7.2 in the manual for more
info. However, GFortran does not support an equivalent to the DEC$
alias attribute, as by the time the GCC attribute syntax was
introduced, there was already a standardized way of doing the same,
namely the bind(C, name="XXX...") specifier. Please see Section 7.1.4
in the manual for more info.
--
Janne Blomqvist