Including a header file from another directory

前端 未结 4 1546
别那么骄傲
别那么骄傲 2021-02-03 18:01

I have a main directory A with two sub directories B and C.

Directory B contains a header file structures.c

4条回答
  •  春和景丽
    2021-02-03 18:29

    If you work on a Makefile project or simply run your code from command line, use

    gcc -IC main.c

    where -I option adds your C directory to the list of directories to be searched for header files, so you'll be able to use #include "structures.h"anywhere in your project.

提交回复
热议问题