Skip to content

Commit 0e45a5a

Browse files
committed
Avoid include a Header more than once
1 parent 076f498 commit 0e45a5a

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

cpp/test/include/head.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef _head_hpp
2+
#define _head_hpp
13
#include <iostream>
24
#include <cstdio>
35
#include <cstdlib>
@@ -22,3 +24,4 @@ struct head_link* add(){
2224
struct head_link *temp=(struct head_link*)malloc(sizeof(struct head_link));
2325
return temp;
2426
}
27+
#endif

cpp/test/include/onebot.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef _onebot_h
2+
#define _onebot_h
3+
#include <cstdio>
4+
#include <cstdlib>
5+
#include <cstring>
6+
#include <iostream>
7+
#endif

cpp/test/include/str.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
#ifndef _str_h
2+
#define _str_h
13
#include <cstdio>
24
#include <cstdlib>
35
#include <cstring>
46
void strval(char **str1,const char *str2,int type);
7+
#endif

cpp/test/src/onebot.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "../include/onebot.h"
2+

0 commit comments

Comments
 (0)