Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
只有页眉的ANSI C库如何可能?_C - Fatal编程技术网

只有页眉的ANSI C库如何可能?

只有页眉的ANSI C库如何可能?,c,C,有一个非常流行的名为的库,它是用ANSIC编写的,并且完全是头文件。但是,每个翻译单元中只能有一个函数定义,而且ANSI C没有内联函数,因此该库如何在没有链接器错误的情况下正常工作?从第73行开始介绍如何使用此标题: /// ## Usage /// This library is self contained in one single header file and can be used either /// in header only mode or in implementatio

有一个非常流行的名为的库,它是用ANSIC编写的,并且完全是头文件。但是,每个翻译单元中只能有一个函数定义,而且ANSI C没有内联函数,因此该库如何在没有链接器错误的情况下正常工作?

从第73行开始介绍如何使用此标题:

/// ## Usage
/// This library is self contained in one single header file and can be used either
/// in header only mode or in implementation mode. The header only mode is used
/// by default when included and allows including this header in other headers
/// and does not contain the actual implementation. <br /><br />
///
/// The implementation mode requires to define  the preprocessor macro
/// NK_IMPLEMENTATION in *one* .c/.cpp file before #includeing this file, e.g.:
///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C
///     #define NK_IMPLEMENTATION
///     #include "nuklear.h"
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
用法 ///该库自包含在一个头文件中,可以使用 ///在仅标头模式或实施模式下。仅使用标题模式 ///默认情况下,当包含时,允许在其他标题中包含此标题 ///并且不包含实际的实现

/// ///实现模式需要定义预处理器宏 ///NK#在包含此文件之前的*one*.c/.cpp文件中实现,例如: /// ///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C ///#定义NK#U实施 ///#包括“nuklear.h” /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
所以通常包括这个头文件只会给你声明。如果在包含前定义NK#U实现,则包含该实现。

C99确实具有内联,并且几乎每个C89编译器都将其作为扩展。另外:
static
。为什么不看一下源代码呢?很确定在C99中添加了
inilne
。首先,现代C确实有
inline
。但是,即使没有
内联
,您也可以声明每个函数
静态
。。。另一种选择是使用特定于平台的东西,比如弱符号(如果你需要全局变量的话)。。。。但最重要的是,查看src目录会发现,它除了头之外,其他都是。。。看看下面有多少.c文件。