Hollerith Constants in Argument Lists (112334)



The information in this article applies to:

  • Microsoft FORTRAN PowerStation for MS-DOS 1.0
  • Microsoft FORTRAN PowerStation for MS-DOS 1.0a
  • Microsoft Fortran Powerstation 32 for Windows NT 1.0
  • Microsoft Fortran Powerstation 32 for Windows NT 4.0

This article was previously published under Q112334

SUMMARY

The use of Hollerith constants outside of a FORMAT specifier is not part of the FORTRAN 77 specification. Any use of Hollerith constants in an argument list is undocumented and unsupported. Using Hollerith can cause the following compiler and linker errors:
F2202: defined with different number of arguments
F2608: Hollerith illegal with CHARACTER
F2624: too few actual arguments
LNK4016: unresolved external symbol
In Microsoft FORTRAN PowerStation, the error generated by the linker is LNK4516.

MORE INFORMATION

When Hollerith constants are used in the argument list of a function or subroutine call, the size of the string is not passed. To the compiler, this looks like references to a function or subroutine with one of the arguments missing. To the linker, this looks like a reference to a different function or subroutine.

To generate the F2202 error, combine B.FOR and D.FOR into one file and compile it:
   copy b.for+d.for test.for
   fl32 /c test.for
				
To generate the F2608 and F2624 errors, combine A.FOR and B.FOR into one file and compile it:
   copy a.for+b.for test.for
   fl32 /c test.for
				
To generate LNK4016, build A.FOR, B.FOR, and either C.FOR or D.FOR:
   fl32 a.for b.for d.for
				
To create a working program that uses both definitions of "TEST", build all four files together:
   fl32 a.for b.for c.for d.for
				
Note that this produces a LNK4006 warning that refers to the undecorated symbol "_TEST". This name is not used by the program, and therefore the warning can be ignored.

Executing A.EXE produces:

Test Quoted: Big Test
Test Hollerith: Big Test

No specific compiler options are required for any of the samples.

Sample Code A.FOR

       call test('Big Test')
       call test_hollerith()
       end
				

Sample Code B.FOR

       subroutine test_hollerith()
       call test(8HBig Test)
       end
				

Sample Code C.FOR

       subroutine test(x)
       real*8 x
       write(*,"(' Test Hollerith: ',A8)") x
       end
				

Sample Code D.FOR

       subroutine test(c)
       character*8 c
       write(*,"(' Test Quoted: ',A8)") c
       end
				

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:kberrmsg KB112334