C问题包括警卫

Ple*_*ugs 0 c header include-guards include

我有一个包含防护设置的头文件.我的项目中有多个C文件,需要这个头文件进行编译.当我去编译但是我得到一个错误,说该函数已经包含在另一个文件中.包括警卫不应该阻止这种情况发生吗?从理论上讲,我相信我应该能够多次导入这个文件而没有这个问题.

#ifndef __BST_INCLUDED
#define __BST_INCLUDED__

//bunch of code here

#endif
Run Code Online (Sandbox Code Playgroud)

错误:

bst.h:22:13: error: conflicting types for ‘pruneBSTNode’
 extern void pruneBSTNode(bst *tree,bstNode *node);
             ^
In file included from vbst.h:5:0,
                 from bstrees.c:7:
Run Code Online (Sandbox Code Playgroud)

use*_*751 5

#ifndef __BST_INCLUDED
#define __BST_INCLUDED__
//bunch of code here
#endif
Run Code Online (Sandbox Code Playgroud)

这不会保护任何东西.原因__BST_INCLUDED__很简单__BST_INCLUDED,并且__BST_INCLUDED永远不会被定义.

但是也:

bst.h:22:13: error: conflicting types for ‘pruneBSTNode’
 extern void pruneBSTNode(bst *tree,bstNode *node);
         ^
In file included from vbst.h:5:0,
                 from bstrees.c:7:
Run Code Online (Sandbox Code Playgroud)

这个错误并没有告诉你"该函数已被包含在另一个文件中",这是一个完全不相关的错误."included from"部分只是告诉你编译器如何到达它后面显示的行(问题中缺少).