Download PGI Compiler User`s Guide
Transcript
Inter-language Calling The following example is pseudocode for the preceding subroutine call using Default conventions: ‣ call _WORK@20 (%addr(‘ERR’), 3, %addr(a), %addr(b), %addr(n)) STDCALL - The symbol name for the subroutine is constructed by pre-pending an underscore, converting to all lower case, and appending an @ sign followed by an integer indicating the total number of bytes occupied by the argument list. Character strings are truncated to the first character in the string, which is passed by value as the first byte in a 4byte word. The following is an example of the pseudocode for the work subroutine call using STDCALL conventions: call _work@20 (%val(‘E’), %val(a), %addr(b), %val(n)) ‣ Notice in this case that there are still 20 bytes in the argument list. However, rather than five 4-byte quantities as in the Default convention, there are three 4-byte quantities and one 8byte quantity (the double precision value of a). C - The symbol name for the subroutine is constructed by pre-pending an underscore and converting to all lower case. Character strings are truncated to the first character in the string, which is passed by value as the first byte in a 4-byte word. The following is an example of the pseudocode for the work subroutine call using C conventions: ‣ call _work (%val(‘E’), %val(a), %addr(b), %val(n)) UNIX - The symbol name for the subroutine is constructed by pre-pending an underscore, converting to all lower case, and appending an underscore. Byte counts for character strings appear in sequence following the last argument in the argument list. The following is an example of the pseudocode for the work subroutine call using UNIX conventions: call _work_ (%addr(‘ERR’), %addr(a), %addr(b), %addr(n),3) 13.9.3. Using the Default Calling Convention The Default calling convention is used if no directives are inserted to modify calling conventions and if neither the -Miface=unix (or –Munix) compilation flag is used. Refer to Symbol Name Construction and Calling Example for a complete description of the Default calling convention. 13.9.4. Using the STDCALL Calling Convention Using the STDCALL calling convention requires the insertion of a compiler directive into the declarations section of any Fortran program unit which calls the STDCALL program unit. You cannot mix UNIX-style argument passing and STDCALL calling conventions within the same file. In the following example syntax for the directive, work is the name of the subroutine to be called using STDCALL conventions: !DEC$ ATTRIBUTES STDCALL :: work PGI Compiler User's Guide 166