Monday, 19 August 2013

C function headers location: .h or .c?

C function headers location: .h or .c?

Suppose we have function (external only considered here) int foo(int a,
char *b), normally there will be a header that goes with it documenting
what the function does, what each parameter and return value does, etc.
It'll probably be in doxygen format too. My habit is that such header
should go into .h files because that's where the interface is defined and
reader should have all the information in that place. But a lot of people
keep such headers in C file where the actual implimentation goes. I've
seen this in the Linux kernel code also. So was I wrong? Which would you
prefer?

No comments:

Post a Comment