paint-brush
Generated Include Guards: An Alternative to pragma onceby@buckaroo.pm
9,062 reads
9,062 reads

Generated Include Guards: An Alternative to pragma once

by Buckaroo - C/C++ Package Manager4mOctober 18th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

In C++, nothing prevents the programmer from including a header-file multiple times. This can cause a duplication of definitions, which is an error. Since it is difficult to ensure that a header-file is only included once, a common strategy is to make only the first include count. This can be done using an “include guard”, a small piece of preprocessor logic that looks like this:

Company Mentioned

Mention Thumbnail
featured image - Generated Include Guards: An Alternative to pragma once
Buckaroo - C/C++ Package Manager HackerNoon profile picture
Buckaroo - C/C++ Package Manager

Buckaroo - C/C++ Package Manager

@buckaroo.pm

L O A D I N G
. . . comments & more!

About Author

Buckaroo - C/C++ Package Manager HackerNoon profile picture
Buckaroo - C/C++ Package Manager@buckaroo.pm

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite