C中.h头文件的写法
来源:互联网 发布:新手如何快速入门seo 编辑:程序博客网 时间:2024/06/11 16:01
C中.h头文件的写法
Michael Barr建议:
1. 系统中为每个功能模块创建一个.h头文件。
一个功能模块实现系统的一个方面功能,它可能由多个.c和.asm文件来实现,为它创建一个.h头文件。
2.把一个模块的公共接口的函数原型放到.h文件中。这是public函数。
3.不要在.h头文件中放私有函数或私有宏, 把它们放到.c文件中,并用static修饰函数。
4.在.h头文件中,不要有执行的代码和变量声明,除非是inline函数。
5.在.h头文件中,不要暴露变量,在.c中声明变量,如果外部需要使用这个变量,在.h中使用extern关键字来暴露变量。
6.在.h头文件中,不要暴露任何特定模块相关的数据结构的内部格式。
在.h头中,不要声明具体数据结构,如struct {...} foo,而是把它放到.c中,如果模块中需要这个结构输入或输出,在头中定义一个类型typedef struct foo module_type,这样客户模块可以创建它的实例。客户模块不必知道具体的foo结构的内部细节。
DON’T expose the internal format of any module-specific data structure passed to or returned from one or more of the module’s interface functions.That is to say there should be no “struct { … } foo;” code in any header file. If you do have a type you need to pass in and out of your module, so client modules can create instances of it, you can simply “typedef struct foo moduleb_type” in the header file. Client modules should never know, and this way cannot know, the internal format of the struct.
- C中.h头文件的写法
- C中.h头文件的写法
- C中.h头文件的写法
- C语言中头文件写法
- C语言模块化中头文件.h的设计
- c语言中time.h头文件的使用
- C语言中.C头文件和.H头文件的概念以及关系
- 01 C++中complex.h头文件的写法(学自Boolan)
- 02 C++中string.h头文件的写法(学自Boolan)
- linux C中 头文件 fcntl.h
- 专业的C/C++头文件写法 (
- c头文件(.h)的作用
- c头文件(.h)的作用
- C、c++ .h 头文件的作用
- c头文件(.h)的作用
- c头文件(.h)的作用
- C-头文件.h的作用
- C++和C中#include包含头文件带 .h 和不带 .h 的区别
- 总结个人网站成功运营的11条原则
- VC Tips
- QThread架构中QObject间通讯常见误区澄清
- how to use Dom to create and remove element
- 大数阶乘思考
- C中.h头文件的写法
- 进程池实现客户端连接请求程序
- Generating Unique Key (Finger Print) for a Computer for Licensing Purposes
- epoll()学习
- SQL union用法
- 程序设计的SOLID原则
- 11第三个放个假低功耗
- 动态规划入门三---背包问题(1)
- [Leetcode] Word Break、Word BreakII