Using MKTYPLIB /h Option to Output C or C++ Style Header file

Last reviewed: October 10, 1997
Article ID: Q124597
2.00 3.50 WINDOWS NT kbole kbtool

The information in this article applies to:

  • The Type Library Generator (MKTYPLIB.EXE), included with:

        - Microsoft Win32 Software Development Kit (SDK) for Windows NT
          version 3.5
        - Microsoft Visual C++, 32-bit Edition, version 2.0
          on the following platform: x86
    

SUMMARY

In addition to generating type libraries, MKTYPLIB can output a C or C++ style header file if you use the optional /h option. When you use the /h option, MKTYPLIB creates a header file with the name specified following the /h option. Any existing file of the same name will be overwritten without warning.

MKTYPLIB always uses the "libraryname" from the LIBRARY keyword in the ODL file to create the #ifndef wrappers in the generated header file, regardless of the name specified for the file on the command line.

MORE INFORMATION

Consider this ODL file (MYPROJ.ODL):

   // example ODL file
   library MYPROJ
   {
      ...
   }

If you run MKTYPLIB on this ODL file by using this command line:

   C:\> MKTYPLIB /h odlfile.h myproj.odl

the ODLFILE.H generated by MKTYPLIB looks like this:

   #ifndef _MYPROJ_H_
   #define _MYPROJ_H_
   ...
   #endif

This can cause problems when compiling source files if another header file also uses _MYPROJ_H_ in its #ifndef wrappers. Only the first file to use _MYPROJ_H_ will actually be included in the source file.

If you are using the _<filename>_H_ convention for #ifndef wrappers, make sure none of your header files have the same name as your type library. Alternatively, use a different naming convention for the #ifndef wrappers in your header files.


Additional reference words: 2.00 3.50
KBCategory: kbole kbtool
KBSubCategory: LeTwoTls


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.

Last reviewed: October 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.