CARVIEW |
Select Language
HTTP/2 200
date: Sat, 19 Jul 2025 04:38:24 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-robots-tag: none
etag: W/"5e5ce43d68fb7765e396e5eaf176faae"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=J1ikSfMPq0xNr6A9bFKoBAEWDdOdGZwCQymvQy10lwK7j2B4M3CLlxYyzq56wm41yulbbBV36v2WrBDGEtBuWiy5E3jSs0U6veTU9VASPP6DHD8g6Sii3lycGSDqMpK6VqUevBN7f%2FT2IZ7SHqL05AP9V7sqJ%2FPJqXgKcljD2TN7p9u4Va6gy8rGoThP5I3H9nyUiS9ms%2BWLYXGhMHSOywD%2BjEC6y7kP48%2FLKsi8juktngDPUp%2Fw5Fcg3Eh0gczLFbTYAljqrjaq4g9hlZj%2F6g%3D%3D--HEhQWeWV%2Fgusfi8z--rqN%2Bhjy56JbpjJJgu9o6bg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1659293861.1752899903; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 04:38:23 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 04:38:23 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: B616:21415F:B34BB:F6AD5:687B213F
Style Guide · PilotLightTech/pilotlight Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 4
Style Guide
Jonathan Hoffstadt edited this page Apr 12, 2024
·
1 revision
General | Variables | Structs | Enums | Functions |
Macros | Defines | Header Files | C Files |
Guidelines:
- meaningful names shall be used for variables, constants, and functions
- variables shall NOT be declared on the same line
- opening braces should be on a new line unless the entire scope is on the same line
- binary operators shall be surrounded by spaces(e.g., x = 3 + 5)
- one space shall be left after commas
- global variables should be avoided where they are unnecessary
- code shall NOT be split into functions unnecessarily
- indentation should use 4 spaces
- heap allocation should be minimized
- tertiary operators shall NOT be nested
- comments shall begin with "//"
Guidelines:
- variables shall use meaningful names
- variables shall follow the following naming convention:
// scalar
int iVariable;
uint32_t uVariable;
uint64_t ulVariable;
size_t szVariable;
bool bVaribale;
// floating point
float fVariable;
double dVariable;
// characters
char cVariable;
unsigned char ucVariable;
// enums & typedefs
plSomeEnum tVariable;
plSomeStruct tVariable;
// pointers
int* piVariable;
uint64_t* pulVariable;
plSomeEnum* ptVariable;
// ... //
char* pcVariable;
void* pvVariable;
// arrays
int aiVariable[16];
uint64_t aulVariable[16];
plSomeEnum atVariable[16];
// ... //
char acVariable[16];
void avVariable[16];
// stretchy buffers
int* sbiVariable;
uint64_t* sbulVariable;
plSomeEnum* sbtVariable;
// ... //
char* sbcVariable;
void* sbvVariable;
// globals
int giVariable;
char* gpcVariable;
Guidelines:
- struct names shall use camel case
- struct names shall be prefixed with "pl"
- structs should always be typedef'd
- structs when containing many members, should have members be grouped into sections
- struct member names should be aligned with other members in their section
- struct private/internal members shall be prefixed with an underscore and placed in the last section labeled "// [INTERNAL]"
- public structs should be forward declared
- structure tags shall match the structure name with a prefixed underscore
- structures should be passed by pointer unless the structure is small
Examples:
// forward declarartion
typedef struct _plPerson plPerson;
// definition
typedef struct _plPerson
{
int iAge;
const char* pcName;
// favorites & misc
float fFavoriteFloat;
int iAnEvenNumber;
// [INTERNAL]
float _fHotness; // 0.0f...10.0f
} plPerson;
Guidelines:
- enum names shall use camel case
- enum names shall be prefixed with "pl"
- enum names shall be appended with an underscore
- enums shall never be used as "types" directly
- enums shall be forward declared using "typedef int plSomeEnumName;"
Examples:
// forward declaration
typedef int plChannelType;
// definition
enum plChannelType_
{
PL_CHANNEL_TYPE_DEFAULT,
PL_CHANNEL_TYPE_CONSOLE,
PL_CHANNEL_TYPE_BUFFER
};
// variable
plChannelType tMyChanelType = PL_CHANNEL_TYPE_CONSOLE;
Guidelines:
- function names shall use snake_case
- function names shall be prefixed with "pl"
- private/internal functions shall have an additional underscore after the "pl" prefix
- function declarations should be on a single line
- most function definitions should start the function signature on a new line
- short and simple functions should be inlined and a single line
- function input arguments shall appear before out arguments
Examples:
// public functions (declarations)
int pl_add_numbers(int iA, int iB);
bool pl_is_button_hovered();
// private/internal functions (declarations)
static float pl__find_average(float fA, float fB);
static void pl__fill_buffer (char* pcBuffer, size_t szSize);
// simple functions
static inline pl__add_numbers(int iA, int iB) { return iA > iB ? iA : iB; }
// definitions
int
pl_add_numbers(int iA, int iB)
{
return iA + iB;
}
static float
pl__find_average(float fA, float fB)
{
return (fA + fB) / 2.0f;
}
Guidelines:
- macros should be uppercase with an underscore between words
- macros should be prefixed with "PL"
- macro arguments shall be surrounded by parenthesis
- new macros shall be created sparingly
- macros used to "compile out" functions should follow the function naming conventions (e.g., logging, profiling)
Examples:
// Guidelines [1][2][3]
#define PL_GET_MAX(x, y) (x) > (y) ? (x) : (y)
// Guideline [5]
#define pl_initialize_profile_context(tPContext) pl__initialize_profile_context((tPContext))
Guidelines:
- preprocessor defines shall be uppercase with an underscore between words
- preprocessor defines shall be prefixed with "PL"
Examples:
#define PL_MAX_GRENADES 1024
Guidelines:
- header file names shall be camel case
- header file names should be short and concise.
- header file names shall be prefixed with "pl_"
- header file names shall be appended with the following for platform dependent headers:
- "_win32" for Windows specifics
- "_linux" for Linux specifics
- "_macos" for MacOs specifics
- "_vulkan" for Vulkan specifics
- "_metal" for Metal specifics
- header files should only include standard headers
- header files should be split into sections with sections denoted as:
//-----------------------------------------------------------------------------
// [SECTION] my section
//-----------------------------------------------------------------------------
- header files should begin with the following:
/*
<header file name>, v0.1 (WIP)
* brief description or notes
*/
/*
Index of this file:
// [SECTION] documentation
// [SECTION] includes
// [SECTION] defines
// [SECTION] forward declarations & basic types
// [SECTION] public api
// [SECTION] enums
// [SECTION] structs
*/
Guidelines:
- c file names shall be camel case
- c file names should be short and concise.
- c file names shall be prefixed with "pl_"
- c file names shall be appended with the following for platform dependent c files:
- "_win32" for Windows specifics
- "_linux" for Linux specifics
- "_macos" for MacOs specifics
- "_vulkan" for Vulkan specifics
- "_metal" for Metal specifics
- c files should be split into sections with sections denoted as:
//-----------------------------------------------------------------------------
// [SECTION] my section
//-----------------------------------------------------------------------------
- c files should begin with the following:
/*
<c file name>, v0.1 (WIP)
* brief description or notes
*/
/*
Index of this file:
// [SECTION] internal documentation
// [SECTION] includes
// [SECTION] defines
// [SECTION] forward declarations & basic types
// [SECTION] internal api
// [SECTION] internal structs
// [SECTION] public api implementations
// [SECTION] internal api implementation
*/
Clone this wiki locally
You can’t perform that action at this time.