“Many security guards included can be useful for” what exactly?

I played with the -H gcc option, which prints information about direct and indirect inclusion in the compilation of C and C ++ (the corresponding section of the gcc manual ).

As part of the output in the section “Multiple protection inclusions can be useful for:", which lists some of the titles of projects and systems.

What does this mean, how is this list determined, and why does it say that “Multiple” includes advocates may be useful?

(I am familiar with the general concept of enabling guards and why you want to use them - I am looking for details about this post, in particular, and what this means for my project.)

+4
source share
1 answer

In this case, "multiple" modifies "includes" and not "guards". Thus, "enable guards" and "multiple inclusion of guards" are one and the same. That is, they protect against multiple inclusions of the same file.

The list is created in this way: firstly, all files are considered for the list. However, the main file is excluded; and files with security enabled; files opened with #import; and files with #pragma once.

The reasons for using guards are because they make the header file idempotent, and they can reduce compilation time. IMO, they are best practice for C and C ++.

+4
source

Source: https://habr.com/ru/post/1616286/


All Articles