forked from RPCS3/rpcs3
-
Notifications
You must be signed in to change notification settings - Fork 4
Coding Style
Alexandro Sánchez Bach edited this page Jan 1, 2014
·
1 revision
We recommend to follow these guidelines when writing code for RPCS3. They aren't very strict rules since we want to be flexible and we understand that under certain circumstances some of them can be counterproductive. Just try to follow as many of them as possible:
- Variable naming: lower_case_underscored
- Globals: g_*
- Class members: m_*
- Statics: s_*
- Avoid
#defines
, use constant variables instead. - Put curly-brackets (
{
and}
) on the next line. - Try to eliminate all compiler warnings from your code.
- Try to use C++ standard data types whenever it's possible (e.g. std::string instead of wxString).
- Module functions and lv2 SysCalls:
- Handle file accesses using VFS functions.
- Return defined error codes. That is, use
return CELL_OK;
instead ofreturn 0;
.
- Use
mem*_t
arguments instead ofu32 *_addr
.- Pointers to
u8
,u16
,u32
,u64
are respectivelymem8_t
,mem16_t
,mem32_t
,mem64_t
. - Pointers to the datatype
foo
aremem_ptr_t<foo>
.
- Pointers to
- Allocate memory with MemoryAllocator.
- Don't forget to switch endianness: That is, allocate
u32
withMemoryAllocator<be_t<u32>>
- Don't forget to switch endianness: That is, allocate