#include<;标准h>;和printf()? #包括 main() printf();

#include<;标准h>;和printf()? #包括 main() printf();,c,c-preprocessor,C,C Preprocessor,预处理器和函数之间有什么联系?当C预处理器读取行#include时,它从系统目录中逐字读取文件stdio.h,并用内容替换该行。然后stdio.h包含printf和其他函数的声明,这些函数告诉C编译器这些函数存在于另一个文件或库中 然后在代码中使用printf()时,编译器知道这个函数,并且知道它不必担心它。(但是,如果没有包含stdio.h,编译器根本不知道函数是什么样子,这可能会很麻烦,编译器会对此抱怨。) 带有printf的示例stdio.h文件可能如下所示: #include <s

预处理器和函数之间有什么联系?

当C预处理器读取行
#include
时,它从系统目录中逐字读取文件
stdio.h
,并用内容替换该行。然后
stdio.h
包含
printf
和其他函数的声明,这些函数告诉C编译器这些函数存在于另一个文件或库中

然后在代码中使用
printf()
时,编译器知道这个函数,并且知道它不必担心它。(但是,如果没有包含
stdio.h
,编译器根本不知道函数是什么样子,这可能会很麻烦,编译器会对此抱怨。)

带有
printf
的示例
stdio.h
文件可能如下所示:

#include <stdio.h>
main()

printf();

当C预处理器读取行
#include
时,它会从系统目录中读取文件
stdio.h
,并用内容替换此行。然后
stdio.h
包含
printf
和其他函数的声明,这些函数告诉C编译器这些函数存在于另一个文件或库中

然后在代码中使用
printf()
时,编译器知道这个函数,并且知道它不必担心它。(但是,如果没有包含
stdio.h
,编译器根本不知道函数是什么样子,这可能会很麻烦,编译器会对此抱怨。)

带有
printf
的示例
stdio.h
文件可能如下所示:

#include <stdio.h>
main()

printf();

当C预处理器读取行
#include
时,它会从系统目录中读取文件
stdio.h
,并用内容替换此行。然后
stdio.h
包含
printf
和其他函数的声明,这些函数告诉C编译器这些函数存在于另一个文件或库中

然后在代码中使用
printf()
时,编译器知道这个函数,并且知道它不必担心它。(但是,如果没有包含
stdio.h
,编译器根本不知道函数是什么样子,这可能会很麻烦,编译器会对此抱怨。)

带有
printf
的示例
stdio.h
文件可能如下所示:

#include <stdio.h>
main()

printf();

当C预处理器读取行
#include
时,它会从系统目录中读取文件
stdio.h
,并用内容替换此行。然后
stdio.h
包含
printf
和其他函数的声明,这些函数告诉C编译器这些函数存在于另一个文件或库中

然后在代码中使用
printf()
时,编译器知道这个函数,并且知道它不必担心它。(但是,如果没有包含
stdio.h
,编译器根本不知道函数是什么样子,这可能会很麻烦,编译器会对此抱怨。)

带有
printf
的示例
stdio.h
文件可能如下所示:

#include <stdio.h>
main()

printf();
标题将以下宏名称定义为正整数常量表达式:

/* stdio.h */

// Declaration of printf
int printf(const char *format, ...);

// And also a bunch of other function declarations...
如您所见,
printf()

中定义,
标题将以下宏名称定义为正整数常量表达式:

/* stdio.h */

// Declaration of printf
int printf(const char *format, ...);

// And also a bunch of other function declarations...
如您所见,
printf()

中定义,
标题将以下宏名称定义为正整数常量表达式:

/* stdio.h */

// Declaration of printf
int printf(const char *format, ...);

// And also a bunch of other function declarations...
如您所见,
printf()

中定义,
标题将以下宏名称定义为正整数常量表达式:

/* stdio.h */

// Declaration of printf
int printf(const char *format, ...);

// And also a bunch of other function declarations...

如您所见,
printf()
是在

中定义的,预处理器指令
#include
只在包含头文件的源文件中包含头文件的源文件

更多信息

因此在本例中,
#include
将在程序中包含
stdio.h
头文件的源


头文件
stdio.h
包含标准输入输出函数的声明,这些函数实际上在libc中定义,动态链接器将libc作为共享库加载到程序地址空间中。

预处理器指令
#include
仅在源文件中包含头文件的源包括在哪里

更多信息

因此在本例中,
#include
将在程序中包含
stdio.h
头文件的源


头文件
stdio.h
包含标准输入输出函数的声明,这些函数实际上在libc中定义,动态链接器将libc作为共享库加载到程序地址空间中。

预处理器指令
#include
仅在源文件中包含头文件的源包括在哪里

更多信息

因此在本例中,
#include
将在程序中包含
stdio.h
头文件的源


头文件
stdio.h
包含标准输入输出函数的声明,这些函数实际上在libc中定义,动态链接器将libc作为共享库加载到程序地址空间中。

预处理器指令
#include
仅在源文件中包含头文件的源包括在哪里

更多信息

因此在这种情况下,
#include
将包含