github / codeql-coding-standards

This repository contains CodeQL queries and libraries which support various Coding Standards.
MIT License
129 stars 59 forks source link

`RULE-2-5`: Identify uses of a macro that occur lexically before the definition #776

Closed lcartey closed 1 month ago

lcartey commented 1 month ago

Affected rules

Description

The extractor identifies uses of a macro that occur after the macro is defined lexically (or within the compilation). However, the standard also considers it an acceptable use if it comes before. Most notably this occurs with header guards.

Example

#ifndef HEADER_GUARD_H
#define HEADER_GUARD_H // COMPLIANT, used above
#endif