首页 > 解决方案 > VSCode包括c中的头文件

问题描述

我正在尝试在 c 中使用我的头文件。当我使用代码块时,它会处理标题包含部分,但在 vs 代码中,我还无法弄清楚。这就是我在 vs 代码中得到的。这些文件位于同一文件夹中。我正在使用 gcc。

#include "assPQ.h"

. . .

PS C:\Users\xxx\Desktop\xxxx\ass> cd "c:\Users\xxx\Desktop\xxxx\ass\" ; if ($?) { gcc coffeeShopSimulator.c -o coffeeShopSimulator } ; if ($?) { .\coffeeShopSimulator }
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\xxx\AppData\Local\Temp\cc6RasGF.o:coffeeShopSimulator.c:(.text+0xf): undefined reference to `CreateListPQ'

标签: cgccvisual-studio-codeheaderinclude

解决方案


我解决了这个问题,可能是因为 VS 代码不是 IDE,你只能通过这样做来链接

#include "header.c"

在主要。

标题本身发生的事情是您需要将“header.h”链接到“header.c”和“header.c”链接到“main.c”。

希望这将有助于任何其他人。如果有其他技术解释,我很高兴听到。


推荐阅读