Browse Prior Art Database

Process & Tool support for Analysing C Header File Inclusion Order

IP.com Disclosure Number: IPCOM000010102D
Original Publication Date: 2002-Oct-23
Included in the Prior Art Database: 2002-Oct-23
Document File: 2 page(s) / 52K

Publishing Venue

IBM

Abstract

The C preprocessor provides a very advanced and flexible tool for C/C++ programmers. One problem that is encountered by programmers is with the use of header files in the order of inclusion. It is quite possible to write header files which mean that the code can work differently according to the order in which the header files are included. The solution presented here allows the order of inclusion of header files to be displayed graphically. By providing graphical feedback problems of mutual inclusion can be identified. This is achieved by taking advantage of the C preprocessor functions to output information during the compilation process. The resultant code is not affected, and no extra code parsing is required. This information is then processed by a graphical tool to show the order of header file inclusion as a tree.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 51% of the total text.

Page 1 of 2

Process & Tool support for Analysing C Header File Inclusion Order

The C preprocessor provides a very advanced and flexible tool for C/C++ programmers.

     One problem encountered by programmers is with the use of header files and their order of inclusion. It is quite possible to write header files which mean that the code can work differently according to the order in which the header files are included. This idea allows the order of inclusion of header files to be graphically determined. By providing graphical feedback problems of mutual inclusion can be identified.

     This is achieved by taking advantage of pre-processor functions to output information during the compilation process. The resultant code is not affected, and no extra code parsing is required.

     This is achieved by building upon a very often use technique in c programs whereby header files will be protected from mutual inclusion by use of a definition.

As usually implemented this works as follows:-

// Header file a.h #ifndef A_H_INCLUDED #define A_H_INCLUDED

// main body of header file here

#endif

     This works by ensuring that once the header file is included A_H_INCLUDED is defined. Any time that this header file is included again, this definition will be defined.

The following additions are made for this technique:

// Header file a.h #ifndef A_H_INCLUDED #define A_H_INCLUDED

#pragma message("<" __FILE__"> include start")

// main body of header file here

#pragma message("<" __FILE__"> include end") #else #...