Liste des Groupes | Revenir à cl c |
On 01/12/2024 15:23, Bart wrote:
You said you didn't want a list of declarations to maintain for static functions within a module.What do you mean here?Such lists might have been helpful to some people decades ago, when editors were more primitive. If I need a list of functions in a file (maybe it's someone else's code, or old code of mine), any programmer's editor or IDE will give me it - updated correctly in real-time, and not out of sync.>
Why isn't this a problem for exported/shared functions?
>
That is, for all sorts of functions and variables declared in headers where there is a declaration in header, and a definition in some 'home' module.
>
I certainly consider it a weakness in C that you don't have clear requirements and limitations for what can be in a header or a C file, or how things can be mixed and matched. Keeping code clear and well-ordered therefore requires discipline and standardised arrangement of code and declarations. Different kinds of projects will have different requirements here, but for my own code I find it best to be strict that for any C file "file.c", there will be a header "file.h" which contains "extern" declarations of any exported functions or data, along with any type declarations needed to support these. My tools will warn on any mismatches, such as non-static functions without a matching "extern" declaration. They can't catch everything - the way C is built up, there is no distinction between external declarations that should be defined in the same module and ones that are imported from elsewhere.Yes, this is why a module scheme (such as the kind I use) is invaluable.
Les messages affichés proviennent d'usenet.