凡在C文件的功能? [英] Where to document functions in C?
问题描述
我有多个文件的C程序,所以我有,例如, stuff.c
它实现的一些功能,而的东西。 ^ h
的函数原型。
I have a C program with multiple files, so I have, for example, stuff.c
which implements a few functions, and stuff.h
with the function prototypes.
我应该如何去评论中记录的功能?
How should I go about documenting the functions in comments?
我应该在头文件中的所有文档,所有的文档中的 .C
文件或复制这两个的文档?我喜欢后一种方式,但后来我遇到问题,我会在其中一人,而不是其他(更新文档通常一个在那里我做了第一次修改,也就是说,如果我第一次修改的头文件,那么它的意见将反映,但如果我更新的实施,只有那些评论会发生变化)。
Should I have all the docs in the header file, all the docs in the .c
file, or duplicate the docs for both? I like the latter approach, but then I run into problems where I'll update the docs on one of them and not the other (usually the one where I make the first modification, i.e. if I modify the header file first, then its comments will reflect that, but if I update the implementation, only those comments will change).
推荐答案
-
把那只使用函数的人需要在头知道的信息。
Put the information that people using the functions need to know in the header.
把该功能维护者需要在源$ C $ C知道的信息。
Put the information that maintainers of the functions need to know in the source code.
这篇关于凡在C文件的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!