What is #ifndef, #define in the header file?

Asked 2 years ago, Updated 2 years ago, 38 views

I saw the source code What are you doing?

#ifndef HEADERFILE_H
#define HEADERFILE_H
...
#endif

c++ pre-processor

2022-09-22 22:33

1 Answers

This is Include guides

If the header file is included, Check if unique value is defined, such as HEADERFILE_H If it is not defined, define it and move on to the next code.

If the header file is re-included, In the first line of ifndef, fail to create the same effect as the inclusion of empty files. By doing this, identifier such as type, enum, and global variables are prevented from being defined several times.


2022-09-22 22:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.