RDK Resources
[*RDK Preferred*]
Code Management Facility
RDK Forums
[RDK Conferences]
RDK Support
Archives
Papers & Presentations Archive
...
Files may contain items in the following order.
Code Block |
---|
/* |
...
* If not stated otherwise in this file or this component's Licenses.txt file the |
...
* following copyright and licenses apply: |
...
* |
...
* Copyright |
...
2020 RDK Management |
...
* |
...
* Licensed under the Apache License, Version 2.0 (the "License"); |
...
* you may not use this file except in compliance with the License. |
...
* You may obtain a copy of the License at |
...
* |
...
* http://www.apache.org/licenses/LICENSE-2.0 |
...
* |
...
* Unless required by applicable law or agreed to in writing, software |
...
* distributed under the License is distributed on an "AS IS" BASIS, |
...
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
...
* See the License for the specific language governing permissions and |
...
* limitations under the License. |
...
*/ |
In all header files, do the following (using the exact file names) to prevent an header file from being included more than once: For example in C do the following
Code Block |
---|
#ifndef FILENAME_H |
...
#define FILENAME_H |
...
// File content |
...
#endif // Last line of code in file |
This is to avoid multiple definitions, and to ensure that the ifndef checks a unique identifier.
...
Identifiers should not exceed 31 characters.
Data Type | Prefix | Sample Variable Names |
int32 | i | iSequenceNo |
unsigned int32 | ui | uiSequenceNo |
int16 | n | nSequenceNo |
unsigned int16 | un | unSequenceNo |
BOOL | b | bTransmitted |
Char | ch | chSequenceNo |
unsigned char | uch | uchSequenceNo |
long | l | lSequenceNo |
unsigned long | ul | ulSequenceNo |
enumerated data type | e | eCapabilityMode |
Arrays | a | int32 aiSequenceNo[10] etc |
Pointers | p | int32 piSequenceNo etc … |
Globals | g | giSequenceNo, gpTimer etc |
Typedef | All the type names shall be suffixed with _t. | Typedef struct _IPAddessInfo { }IPAddressInfo_t; |
Only one statement should exist per line.
...
Conditional statements found in if, while, do etc. should be explicit based on the data type of variable tested for.
for e.g. in C++
|
Inaccessible code should be avoided. Care should be taken when using GOTO or return statement .
...
The null body of a "for" or "while" loop should be alone on a line and commented so that it is clear that the null body is intentional and not missing code.
|
All control statements should be followed by an indented code block enclosed with braces, even if it only contains one statement. This makes the code consistent and allows the block to be
easily expanded in the future.
For example in C++ use :
|
...
Type | Public | Internal |
---|---|---|
Packages | lower_with_under | |
Modules | lower_with_under | _lower_with_under |
Classes | CapWords | _CapWords |
Exceptions | CapWords | |
Functions | lower_with_under() | _lower_with_under() |
Global/Class Constants | CAPS_WITH_UNDER | _CAPS_WITH_UNDER |
Global/Class Variables | lower_with_under | _lower_with_under |
Instance Variables | lower_with_under | _lower_with_under (protected) or __lower_with_under (private) |
Method Names | lower_with_under() | _lower_with_under() (protected) or __lower_with_under() (private) |
Function/Method Parameters | lower_with_under | |
Local Variables | lower_with_under |
-
) in any package/module name__double_leading_and_trailing_underscore__
names (reserved by Python)...