xxx。h:致命错误C1083:不能打开包含文件:yyyy。没有这样的文件或目录。

时间:2022-11-26 18:12:30

I am working with a c project, where I need to include a header file which has few other header files. When I tried to compile compiler is also looking for header files included in the header file I am using.

我正在使用一个c项目,在那里我需要包含一个头文件,它没有其他的头文件。当我尝试编译编译器时,也在查找包含在我正在使用的头文件中的头文件。

To be more clear, I am need of using xxx.h file in my current program which has only one useful function to me. But xxx.h file got some other yyy.h included in it.
When I compile I am having the below error:

更清楚的是,我需要使用xxx。h文件在我当前的程序中,它对我只有一个有用的功能。但是xxx。h文件还有其他yyy。h。当我编译时,我有以下错误:

xxx.h: fatal error C1083: Cannot open include file: yyy.h: No such file or directory

xxx。h:致命错误C1083:不能打开包含文件:yyy。h:没有这样的文件或目录。

Anyone can please suggest me a way to include xxx.h file and use the only one function I need with including yyy.h to my current project?

任何人都可以建议我加入xxx。h文件,并使用我需要的唯一一个功能,包括yyy。h对我现在的项目?

1 个解决方案

#1


1  

use #ifdef blocks to prevent the unwanted headers to be included.

使用#ifdef块来防止包含不需要的标题。

Lets say you need a a prototype of a function , other than this you do not need anything. Then :

假设您需要一个函数的原型,除了这个,您不需要任何东西。然后:

#ifndef MY_APP
#include <notneeded1.h>
#include <notneeded2.h>
.............
.............
#endif
#ifdef MY_APP
void my_needed_foo_bar()
#endif

#ifndef MY_APP
.....
#endif

Now compile your app with defining MY_APP

现在通过定义MY_APP编译你的应用程序。

Like in gcc

像在海湾合作委员会

$gcc -DMY_APP ....

#1


1  

use #ifdef blocks to prevent the unwanted headers to be included.

使用#ifdef块来防止包含不需要的标题。

Lets say you need a a prototype of a function , other than this you do not need anything. Then :

假设您需要一个函数的原型,除了这个,您不需要任何东西。然后:

#ifndef MY_APP
#include <notneeded1.h>
#include <notneeded2.h>
.............
.............
#endif
#ifdef MY_APP
void my_needed_foo_bar()
#endif

#ifndef MY_APP
.....
#endif

Now compile your app with defining MY_APP

现在通过定义MY_APP编译你的应用程序。

Like in gcc

像在海湾合作委员会

$gcc -DMY_APP ....