I am studying COM so there're some basic questions puzzling me...
I know that IDL file is used to describe the method definitions (or the so called 'contract' between software modules), and the .H header files contains something like a method prototype, which looks similar to what the IDL is meant for. So, why are these two things coexist? Isn't one enough?
Many thanks.
A file saved with h file extension is a header file used in C/C++ files to include the declaration of variables, constants, and functions. These are referred by the C++ implementation files that contain the actual implementation of these functions.
The difference between a header file and library file is that header file contains the function declarations to be shared between several source files while library file is a file that contains the function definition for the declared functions in the header file.
There are of 2 types of header file: Pre-existing header files: Files which are already available in C/C++ compiler we just need to import them. User-defined header files: These files are defined by the user and can be imported using “#include”.
Header files ( . h ) are designed to provide the information that will be needed in multiple files. Things like class declarations, function prototypes, and enumerations typically go in header files.
Interface description language (IDL) is a small language in itself which provides a programming language independent way to describe an interface. Tools generate .h files from your .idl.
If you only had a .h file it would be impossible to tie into it with another programming language. .h files are very specific to C and C++ code only.
Some other differences are that in .h files you can sometimes have implementation as well as declaration, as well as class member variables. Whereas in IDL you are strictly defining an interface.
From Wikipedia:
An interface description language (or alternately, interface definition language), or IDL for short, is a specification language used to describe a software component's interface. IDLs describe an interface in a language-neutral way, enabling communication between software components that do not share a language – for example, between components written in C++ and components written in Java.
On the other hand, .H files are used exclusively by the C/C++ compiler in order to generate code-object. So, they are language specific.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With