"Fossies" - the Fresh Open Source Software Archive

Member "exiv2-0.27.6-Source/CODING_GUIDELINES.md" (18 Jan 2023, 4483 Bytes) of package /linux/misc/exiv2-0.27.6-Source.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the last Fossies "Diffs" side-by-side code changes report for "CODING_GUIDELINES.md": 0.27.0_vs_0.27.1.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


Coding Guidelines

Contents

1. General Guidelines

2. Integer and Array Overflows

const uint32_t some_var = get_var();
const uint16_t lower_2_bytes = (const uint16_t*) &some_var;

since this will give you the upper two bytes on big endian systems. If in doubt, then use the fixed size integer types like int32_t, uint64_t, size_t, etc.

3. Code Formatting

The project contains a .clang-format.optional file defining the code formatting of the project (more details about of this file was defined can be found in this PR). We do not provide it via the standard name (.clang-format), since we do not enforce code formatting and do not want editors to automatically format everything.

Nevertheless, we suggest you to respect the code formatting by symlinking .clang-format.optional to .clang-format and applying clang-format to new or existing code. You can do it by using the clang-format command-line tool or by using one of the integration plugins provided by various editors or IDEs. Currently we know about these integrations:

Note that some times the formatting applied to complex code might result in some unexpected output. If you know how to improve the current .clang-format file to deal with such cases, then please contribute!. Otherwise, you have two options:

  1. Apply clang-format to individual blocks of code (avoid to apply it over the complex piece of code).
  2. Indicate which parts of the code that should not be clang-format formatted:
// clang-format off
    void    unformatted_code  ;
// clang-format on

3.1 Guidelines to Apply clang-format

More information about clang: