How to interface fortran application with C code without getting compiler errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Whittle
    New Member
    • Oct 2010
    • 1

    How to interface fortran application with C code without getting compiler errors

    I have an application written in Intel Fortran that needs to call a C library routine. I do not need to pass three of the arguments and the C documentation says that they can be NULL.

    I have set up the INTERFACE structure shown below, and have used this approach extensively for years with other C routines, but have never needed to pass a NULL before.

    The first dummy argument is "char *" and the other two are "char **".

    I have tried passing NULL() but the compiler complains that "This name has not been declared as an array or a function".

    Code:
          INTERFACE
            INTEGER FUNCTION GRBloadmodel (
            .................. other arguments ...
         +                                 vtype,
         +                                 varnames,
         +                                 constrnames
         +                                )
              !DEC$ ATTRIBUTES STDCALL, ALIAS:"GRBloadmodel"::GRBloadmodel
              .................. other arguments ...
              CHARACTER*(*)    vtype
              !DEC$ ATTRIBUTES REFERENCE::vtype
              CHARACTER*(*)    varnames(*)
              CHARACTER*(*)    constrnames(*)
            END FUNCTION GRBloadmodel
          END INTERFACE
Working...