coding style - C function headers location: .h or .c? -


this question has answer here:

suppose have function (external considered here) int foo(int a, char *b), there header goes documenting function does, each parameter , return value does, etc. it'll in doxygen format too. habit such header should go .h files because that's interface defined , reader should have information in place. lot of people keep such headers in c file actual implimentation goes. i've seen in linux kernel code also. wrong? prefer?

although header files can used in way, mechanism enable external linkage.

you design api meant external consumption, , put required consume api (constants, types, prototypes) in header file(s).

all other stuff, part of implementation, , doesn't need seen external users, can go in source files (if usage localized 1 file), or private headers can shared between multiple files. latter example of header files enabling external linkage, internal consumption.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -