包括路径问题 [英] Include path question

查看:50
本文介绍了包括路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

假设存在foo / bar.h,并且在

foo / bar中包含为''#include" bar.h"''。 C。 `gcc -c foo / bar.c`将编译好(即找到

文件)。这是一个gcc扩展或C编译器标准功能

foo /将被搜索而不显式传递-Ifoo?


$ cat foo / bar.h

#define目标1


$ cat foo / bar.c

#include< stdio.h>

#include" bar.h"

int main(void){

printf("%d \ n",GOAL);

返回0;

}


-`J''

-

Hello,
assume foo/bar.h exists, and is included as ''#include "bar.h"'' in
foo/bar.c. `gcc -c foo/bar.c` will compile it fine (i.e. finds the
file). Is this a gcc extension or a C compiler standard feature that
foo/ will be searched without explicitly passing -Ifoo?

$ cat foo/bar.h
#define GOAL 1

$ cat foo/bar.c
#include <stdio.h>
#include "bar.h"
int main(void) {
printf("%d\n", GOAL);
return 0;
}

-`J''
--

推荐答案

cat foo / bar.h

#define目标1

cat foo/bar.h
#define GOAL 1

cat foo / bar.c

#include< stdio.h>

#include" bar.h"

int main(void){

printf("%d \ n",GOAL);

返回0;

}


-`J''

-
cat foo/bar.c
#include <stdio.h>
#include "bar.h"
int main(void) {
printf("%d\n", GOAL);
return 0;
}

-`J''
--


Jan Engelhardt说:
Jan Engelhardt said:

你好,


假设foo / bar.h存在,并包括在内''#include" bar.h"''在

foo / bar.c中。 `gcc -c foo / bar.c`将编译好(即找到

文件)。这是一个gcc扩展或C编译器标准功能

foo /将被搜索而不显式传递-Ifoo?
Hello,
assume foo/bar.h exists, and is included as ''#include "bar.h"'' in
foo/bar.c. `gcc -c foo/bar.c` will compile it fine (i.e. finds the
file). Is this a gcc extension or a C compiler standard feature that
foo/ will be searched without explicitly passing -Ifoo?



标准没有指定与

实现接口的详细信息。


- -

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上面的域名(但显然放弃了www)

The Standard does not specify the details of interfacing with an
implementation.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)


这篇关于包括路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆