Microsoft KB Archive/70665

ADS of Pascal Procedure Requires [public] Declaration PSS ID Number: Q70665 Article last modified on 04-03-1991 PSS database name: S_PasCal

3.32 4.00 | 3.32 4.00

MS-DOS | OS/2

Summary:

When using the ADS function to return the address of a procedure or function, a null pointer is always returned. To work around this problem, declare the procedure or function with the [public] attribute.

Microsoft has confirmed this to be a problem with the Microsoft Pascal Compiler versions 3.32 and 4.00 for MS-DOS and MS OS/2. We are researching this problem and will post more information here as it becomes available.

The program example on page Update-49 in the “Microsoft Pascal Compiler: Version 4.0 Update” manual does not work correctly. To correct this problem, add a [public] attribute to the definition of the pproc and pfunc procedures.

More Information:

The program below (ADSTEST.PAS) demonstrates this problem. When executed, ADSTEST.PAS should print the address (segment:offset) of the dummy procedure. Instead, ADSTEST.PAS prints 0:0, which is a null pointer and is invalid. If you add the [public] attribute to the procedure definition, the program will work correctly.

Code Sample, ADSTEST.PAS
program AdsTest(output);

var ptr : adsproc;

{ Replace the procedure definition below with “procedure dummy [public];” to correct the program: } procedure dummy; begin writeln; end;

begin ptr := ads dummy; writeln(ptr.s:1, ‘:’, ptr.r:1); end.

Copyright Microsoft Corporation 1991.