The below wiki article is based on user submitted content. Please verify all hyperlinks and terminal commands below!
See a mistake? Want to contribute? Edit this article on Github
The issue tracker is not a support forum. Unless you can provide precise technical information regarding an issue, you should not post in it. If you need support, first read the FAQ and then either visit our Discord server, our forum or ask in a general emulation forum such as /r/emulation. If you post support questions, generic messages to the developers or vague reports without technical details, they will be closed and locked.
If you believe you have a valid issue report, please post text or a screenshot from the log (the console window that opens alongside yuzu) and build version (hex string visible in the titlebar and zip filename), as well as your hardware and software information if applicable.
yuzu is a brand new project, so we have a great opportunity to keep things clean and well organized early on. As such, coding style is very important when making commits. We run clang-format on our CI to check the code. Please use it to format your code when contributing. However, it doesn’t cover all the rules below. Some of them 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.
When generating the native build script for your toolset, cmake will try to find the correct version of clang format (or will download it on windows). Before running cmake, please install clang format version 10.0 for your platform as follows:
brew install clang-format
.sudo dnf install clang-tools-extra
).If clang format is found, then cmake will add a custom build target that can be run at any time to run clang format against all source files and update the formatting in them. This should be used before making a pull request so that the reviewers can spend more time reviewing the code instead of having to worry about minor style violations. On MSVC, you can run clang format by building the clang-format project in the solution. On macOS, you can either use the Makefile target make clang-format
or by building the clang-format target in XCode. For Makefile builds, you can use the clang-format target with make clang-format
static_cast
and reinterpret_cast
. Try to avoid using dynamic_cast
. Never use const_cast
except for when dealing with external const-incorrect APIs.PascalCase
lower_case_underscored
. Prefix with g_
if global.PascalCase
lower_case_underscored
PascalCase
, _
may also be used for clarity (e.g. ARM_InitCore
)Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spaces instead.
//
) comments, even for multi-line ones.///
if it’s a single line, else use the /**
*/
style featured in the example. Start the text on the second line, not the first containing /**
.// Includes should be sorted lexicographically
// STD includes first
#include
#include
#include
// then, library includes
#include
// finally, yuzu includes
#include "common/math_util.h"
#include "common/vector_math.h"
// each major module is separated
#include "video_core/pica.h"
#include "video_core/video_core.h"
namespace Example {
// Namespace contents are not indented
// Declare globals at the top (better yet, don't use globals at all!)
int g_foo{}; // {} can be used to initialize types as 0, false, or nullptr
char* g_some_pointer{}; // Pointer * and reference & stick to the type name, and make sure to initialize as nullptr!
/// A colorful enum.
enum class SomeEnum {
Red, ///< The color of fire.
Green, ///< The color of grass.
Blue, ///< Not actually the color of water.
};
/**
* Very important struct that does a lot of stuff.
* Note that the asterisks are indented by one space to align to the first line.
*/
struct Position {
// Always intitialize member variables!
int x{};
int y{};
};
// Use "typename" rather than "class" here
template
void FooBar() {
const std::string some_string{"prefer uniform initialization"};
const std::array some_array{
5,
25,
7,
42,
};
if (note == the_space_after_the_if) {
CallAFunction();
} else {
// Use a space after the // when commenting
}
// Place a single space after the for loop semicolons, prefer pre-increment
for (int i = 0; i != 25; ++i) {
// This is how we write loops
}
DoStuff(this, function, call, takes, up, multiple,
lines, like, this);
if (this || condition_takes_up_multiple &&
lines && like && this || everything ||
alright || then) {
// Leave a blank space before the if block body if the condition was continued across
// several lines.
}
// No indentation for case labels
switch (var) {
case 1: {
const int case_var{var + 3};
DoSomething(case_var);
break;
}
case 3:
DoSomething(var);
return;
default:
// Yes, even break for the last case
break;
}
}
} // namespace Example
Advertisement
Advertisement