Q112334: Hollerith Constants in Argument Lists

Article: Q112334
Product(s): Microsoft Fortran Compiler
Version(s): 1.0,1.0a,4.0
Operating System(s): 
Keyword(s): kberrmsg
Last Modified: 02-NOV-1999

-------------------------------------------------------------------------------
The information in this article applies to:

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

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

Additional query words: kbinf 1.00 4.00

======================================================================
Keywords          : kberrmsg 
Technology        : kbAudDeveloper kbFortranSearch kbZNotKeyword2 kbZNotKeyword3 kbFORTRANPower32100NT kbFORTRANPower32400NT kbFORTRANPower100DOS kbFORTRANPower100aDOS
Version           : :1.0,1.0a,4.0

=============================================================================