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

ID: Q124597


The information in this article applies to:
  • The Type Library Generator (MKTYPLIB.EXE), used with:
    • Microsoft Win32 Software Development Kit (SDK), version 3.5
      on the following platforms: Windows NT
    • Microsoft Visual C++, 32-bit Editions, version 2.0


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:

<FIXEDTEXT><![CDATA[
   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 query words: 2.00 3.50

Keywords : kbole kbNTOS350 kbSDKWin32 kbVC200 kbGrpCom kbDSupport
Version : :
Platform :
Issue type :


Last Reviewed: October 26, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.