CodeQL library for C/C++
codeql/cpp-all 2.1.1-dev (changelog, source)
Search

Module MultipleInclusion

Provides definitions related to include guards: techniques for preventing multiple inclusion of header files.

Import path

import semmle.code.cpp.headers.MultipleInclusion

Imports

cpp

Provides classes and predicates for working with C/C++ code.

Predicates

correctIncludeGuard

Holds if hf uses a valid include guard with the macro named includeGuard and the preprocessor directives ifndef, define, and endif. This analysis is also exposed in an object-oriented style through the class CorrectIncludeGuard.

endsWithEndif

Holds if hf ends with endif.

hasIncludeGuard

Holds if hf begins with an #ifndef or #if directive ifndef, to test the macro named includeGuard, and ends with the matching endif.

ifndefDirective

Holds if ppd is effectively an #ifndef directive that tests macro. This includes #if !defined(macro).

startsWithIfndef

Holds if hf begins with an #ifndef or #if directive ifndef, to test the macro named macroName.

Classes

BadIncludeGuard

A header file that uses a non-portable mechanism to prevent multiple inclusion.

CorrectIncludeGuard

A header file with the correct include guard: #ifndef (or equivalent), #define, and #endif.

EmptyFile

A file with no code in it.

IncludeGuardedHeader

A header file with an include guard.

PragmaOnceIncludeGuard

A header file with the #pragma once include guard.