Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the different purpose of .H header file and a IDL file?

Tags:

c++

com

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.

like image 745
smwikipedia Avatar asked Apr 12 '10 17:04

smwikipedia


People also ask

What is the purpose of .h header file?

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.

What is different between header file and library file what is the purpose of header file is the use of header file absolutely required?

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.

What are two types of header files?

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”.

Why do we have header ie * .h files?

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.


2 Answers

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.

like image 84
Brian R. Bondy Avatar answered Sep 22 '22 15:09

Brian R. Bondy


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.

like image 42
Bruno Brant Avatar answered Sep 19 '22 15:09

Bruno Brant