0

I am working on compiling an old piece of Fortran code written sometime in the early 2000s. In this code base there are functions designed to interface with C code and have the following structure:

SUBROUTINE F_LIB_FOO(MY_VAR)
   !DEC$ ATTRIBUTES DLLEXPORT,STDCALL :: F_LIB_FOO
   REAL(8), INTENT(IN) :: MY_VAR [REFERENCE]
   LIB_FOO(MY_VAR) !This calls the function implemented internally

However, when I try to compile it using gfortran 4.4.7 I get the following error

REAL(8), INTENT(IN) :: MY_VAR  [REFERENCE]
                             1
Error: Syntax error in data declaration at (1)

My belief is that REFERENCE indicates that the MY_VAR is passed by reference. However, I can't find any examples that use this sort of syntax.

According to this answer, this syntax is supported in Visual Studios. I want to know if there is a similar way to do this in a Linux machine and if there isn't, how can I change the code to compile with gfortran and have the same functionality.

Iliketoproveit
  • 445
  • 6
  • 15

1 Answers1

0

As the linked answer says, the [REFERENCE] attribute is a highly non-standard thing that changes the behaviour for STDCALL calling conventions. Stdcall is the standard calling convention for the Microsoft Win32 API and for Open Watcom C++.

You can safely delete it for Linux programs and for 64-bit Windows as well.

For situations (Win32), where it might be necessary, GCC uses !GCC$ ATTRIBUTES STDCALL, but I am not sure how to specify REFERENCE there.