Microsoft KB Archive/70665

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 19:29, 12 August 2020 by X010 (talk | contribs) (X010 moved page Microsoft KB Archive/Q70665 to Microsoft KB Archive/70665 without leaving a redirect: Text replacement - "Microsoft KB Archive/Q" to "Microsoft KB Archive/")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.