Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

raylib coding conventions

wahyu-mayar edited this pageOct 27, 2025 ·12 revisions

This page list some coding conventions rules I try to follow on raylib C code:

Code elementConventionExample
MacrosALL_CAPS#define MIN(a,b) (((a)<(b))?(a):(b))
DefinesALL_CAPS#define PLATFORM_DESKTOP
ConstantslowerCaseconst int maxValue = 8
StructTitleCasestruct Texture2D
Struct memberslowerCasetexture.id
EnumTitleCaseTextureFormat
Enum membersALL_CAPSPIXELFORMAT_UNCOMPRESSED_R8G8B8
FunctionsTitleCase or prefixTitleCaseInitWindow()/rlLoadTexture()
VariableslowerCasescreenWidth
Local variableslowerCaseplayerPosition
Global variableslowerCasefullscreen
Operatorsvalue1*value2int product = value*6;
Operatorsvalue1/value2int division = value/4;
Operatorsvalue1 + value2int sum = value + 10;
Operatorsvalue1 - value2int res = value - 5;
PointersMyType *pointerTexture2D *array;
float valuesalways x.xffloat value = 10.0f
Ternary Operator(condition)? result1 : result2printf("Value is 0: %s", (value == 0)? "yes" : "no");

Some other conventions to follow:

  • raylib code does not use TABS, use 4 spaces instead.

  • Control flow statements are always followed by a space:

if (condition)value=0;while (!WindowShouldClose()){}for (inti=0;i<NUM_VALUES;i++)printf("%i",i);switch (value){case0:    {    }break;case2:break;default:break;}
  • All condition checks are always enclosed in parentheses, with the exception of simple boolean values:
if ( (value>1)&& (value<50)&&valueActive ){}
  • When dealing with curly braces, open-close them in aligned mode, it's more visual for students:
voidSomeFunction(){// TODO: Do something here!}

When proposing new functions, please try to use a clear naming for function-name and function-parameters. In case of doubt, open an issue for discussion.

www.raylib.com  |  itch.io  |  GitHub  |  Discord  |  YouTube

Library Design

Development Platforms

IDE Configurations

Misc Help

Wiki History

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp