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

ID: Q124597

2.00 3.50 WINDOWS NT kbole kbtool

The information in this article applies to:

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

Last Reviewed: October 10, 1997