File tree Expand file tree Collapse file tree 3 files changed +56
-1
lines changed
Expand file tree Collapse file tree 3 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 4646 - name : Setup Pages
4747 uses : actions/configure-pages@main
4848 - name : Upload artifact
49- uses : actions/upload-pages-artifact@v1
49+ uses : actions/upload-pages-artifact@main
5050 with :
5151 # Upload entire repository
5252 path : ' doc/_build/html/'
Original file line number Diff line number Diff line change 1+ {
2+ "cells" : [
3+ {
4+ "cell_type" : " markdown" ,
5+ "metadata" : {},
6+ "source" : [
7+ " # `#ifndef`\n " ,
8+ " \n " ,
9+ " `#ifndef` 是 C++ 预处理器指令之一,用于检查宏是否已经被定义。如果宏没有被定义,那么编译器会执行后面的代码块。这个指令通常与 `#define` 和 `#endif` 一起使用,用于防止头文件的重复包含。\n " ,
10+ " \n " ,
11+ " 下面示例代码,展示了如何使用 `#ifndef` 来避免头文件的重复包含:"
12+ ]
13+ },
14+ {
15+ "cell_type" : " code" ,
16+ "execution_count" : 1 ,
17+ "metadata" : {},
18+ "outputs" : [],
19+ "source" : [
20+ " #ifndef HEADER_H\n " ,
21+ " #define HEADER_H\n " ,
22+ " \n " ,
23+ " // 在这里放置头文件中的代码\n " ,
24+ " \n " ,
25+ " #endif // HEADER_H"
26+ ]
27+ },
28+ {
29+ "cell_type" : " markdown" ,
30+ "metadata" : {},
31+ "source" : [
32+ " 在上面的代码中,`#ifndef HEADER_H` 检查宏 `HEADER_H` 是否已经被定义。如果没有被定义,那么编译器会执行 `#define HEADER_H` 语句,将宏定义添加到预处理器的符号表中。然后,编译器会继续编译后续的代码,直到遇到 `#endif` 指令。\n " ,
33+ " \n " ,
34+ " 通过这种方式,可以确保头文件只被包含一次,从而避免了重复定义和潜在的错误。"
35+ ]
36+ }
37+ ],
38+ "metadata" : {
39+ "kernelspec" : {
40+ "display_name" : " C++14" ,
41+ "language" : " C++14" ,
42+ "name" : " xcpp14"
43+ },
44+ "language_info" : {
45+ "codemirror_mode" : " text/x-c++src" ,
46+ "file_extension" : " .cpp" ,
47+ "mimetype" : " text/x-c++src" ,
48+ "name" : " c++" ,
49+ "version" : " 14"
50+ }
51+ },
52+ "nbformat" : 4 ,
53+ "nbformat_minor" : 2
54+ }
Original file line number Diff line number Diff line change 66
77binary-code
88float
9+ ifndef
910```
You can’t perform that action at this time.
0 commit comments