diff options
author | Eduardo Habkost | 2019-08-13 01:46:30 +0200 |
---|---|---|
committer | Paolo Bonzini | 2019-08-20 20:00:51 +0200 |
commit | b87c8cdb3e838f282c878a8ddb4c598e0d0ec559 (patch) | |
tree | aee8ef1cc43016f42699e026e812cfaff71e597d /HACKING | |
parent | kvm: vmxcap: Enhance with latest features (diff) | |
download | qemu-b87c8cdb3e838f282c878a8ddb4c598e0d0ec559.tar.gz qemu-b87c8cdb3e838f282c878a8ddb4c598e0d0ec559.tar.xz qemu-b87c8cdb3e838f282c878a8ddb4c598e0d0ec559.zip |
HACKING: Document 'struct' keyword usage
Sometimes we use the 'struct' keyword in headers to help us
reduce dependencies between header files. Document that
practice.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'HACKING')
-rw-r--r-- | HACKING | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -100,7 +100,19 @@ pointer, you're guaranteed that it is used to modify the storage it points to, or it is aliased to another pointer that is. 2.3. Typedefs -Typedefs are used to eliminate the redundant 'struct' keyword. + +Typedefs are used to eliminate the redundant 'struct' keyword, since type +names have a different style than other identifiers ("CamelCase" versus +"snake_case"). Each named struct type should have a CamelCase name and a +corresponding typedef. + +Since certain C compilers choke on duplicated typedefs, you should avoid +them and declare a typedef only in one header file. For common types, +you can use "include/qemu/typedefs.h" for example. However, as a matter +of convenience it is also perfectly fine to use forward struct +definitions instead of typedefs in headers and function prototypes; this +avoids problems with duplicated typedefs and reduces the need to include +headers from other headers. 2.4. Reserved namespaces in C and POSIX Underscore capital, double underscore, and underscore 't' suffixes should be |