TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Category: Portability

Synopsis:Being Platform Independent


Description:
This chapter concerns the ability of code to be transferred from one environment to another. Some aspects of the environment may be: the operating system, the hardware platform, the compiler, the GUI, the user's language and localization.

Coding Rules

NameCheckedSynopsis
POR#001 Checked automatically with code checker Never use absolute file paths
POR#002 Do not assume that an int and a long have the same size
POR#003 Checked automatically with code checker Do not assume that a char is signed or unsigned
POR#004 Checked automatically with code checker Do not cast a pointer to a shorter quantity to a pointer to a longer quantity
POR#005 Checked automatically with code checker Do not assume that pointers and integers have the same size
POR#006 Checked automatically with code checker Use explicit type conversions for arithmetic using signed and unsigned values
POR#007 Do not assume that you know how an instance of a data type is represented in memory
POR#008 Do not depend on underflow or overflow functioning in any special way
POR#009 Do not assume that longs, floats, doubles or long doubles may begin at arbitrary addresses
POR#010 Do not assume that the operands in an expression are evaluated in a definite order, unless the order is specified in the language
POR#011 Do not assume that you know how the invocation mechanism for a method or function is implemented
POR#012 Do not assume that static objects are initialized in any special order when they are spread over multiple source files
POR#014 Do not assume that a short is 16-bits
POR#015 Do not assume that a long is 32-bits
POR#016 Do not assume that the size of an enumeration is the same for all platforms
POR#017 Do not depend on undefined, unspecified, or implementation-defined parts of the language
POR#018 Checked automatically with code checker Avoid the use of #pragma directives
POR#019 Checked automatically with code checker Header file names shall always be treated as case-sensitive
POR#020 Do not make assumptions about the exact size or layout in memory of an object
POR#021 Checked automatically with code checker Avoid the use of conditional compilation
POR#022 Make sure all conversions from a value of one type to another of a narrower type do not slice off significant data
POR#023 Use typedefs or classes to hide the representation of application-specific data types
POR#024 Use macros to prevent the use of unsupported keywords
POR#025 Checked automatically with code checker Floating point values shall not be compared using the == or != operators
POR#026 Only one #include directive should be needed when using a template
POR#027 Do not rely on partial instantiation of templates
POR#028 Checked automatically with code checker Always return a value from main
POR#029 Checked automatically with code checker Do not depend on the order of evaluation of arguments to a function
POR#030 Both operands of the remainder operator shall be positive
POR#031 Checked automatically with code checker Do not depend on implementation defined behavior of shift operators for built-in types
POR#032 Checked automatically with code checker Use nullptr instead of 0 or NULL for a null pointer
POR#033 Checked automatically with code checker Do not make assumptions on the size of int
POR#034 Checked automatically with code checker Avoid using shift operations instead of arithmetic operations
POR#035 Checked automatically with code checker Headers supplied by external libraries go in <> brackets; all other headers go in "" quotes
POR#036 If an object is created using a default constructor, then don't use parenthesis in the declaration
POR#037 Checked automatically with code checker Avoid the use of #pragma warning directive.
POR#038 Make sure that the sizes and types of functions are well-defined if exported to other languages