KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q46270: Typedef of Function Pointer with _loadds Fails

Article: Q46270
Product(s): See article
Version(s): 5.10   | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | SR# G890616-20706 | mspl13_c
Last Modified: 11-SEP-1989

Question:

I have the following typedef declaration:

typedef  void far _loadds pascal MYFUNC(void);
typedef  MYFUNC  far *PMYFUNC;

The second typedef gives a compiler warning (at -W3 level):

   Warning C4105: 'PMYFUNC' : code modifiers only on function
   or pointer to function

How can I avoid the warning?

Response:

This compiler does not handle this situation properly.

One solution is to use a macro as shown below:

    #define FN_FLP far _loadds pascal

    void FN_FLP myfunc1();

    void (FN_FLP *pmyfunc1)();

This isn't as attractive as a typedef, but it does help.

Another way to work around the problem is to put the definition of the
function in a different source file than the calls, leaving the
_loadds keyword in the function definition but taking it out of the
declarations. Since _loadds does not affect the calling sequence, this
process should not cause additional problems.

Note: Be sure to check your generated code.

Microsoft is researching this problem and will post new information as
it becomes available.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.