This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set X_FLAGS=-DBUILD_SHARED_LIBS=NO -DSFML_USE_STATIC_STD_LIBS=YES ^ | |
-DSFML_BUILD_EXAMPLES=NO -DSFML_BUILD_DOC=NO -G "MinGW Makefiles" | |
if not exist "%~dp0Debug.Build" mkdir "%~dp0Debug.Build" | |
if not exist "%~dp0SFML.Debug" mkdir "%~dp0SFML.Debug" | |
if not exist "%~dp0Release.Build" mkdir "%~dp0Release.Build" | |
if not exist "%~dp0SFML.Release" mkdir "%~dp0SFML.Release" | |
:: Build and install to Debug dir | |
pushd "%~dp0Debug.Build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cassert> | |
#include <cstdio> | |
#include <iostream> | |
class File | |
{ | |
public: | |
// Конструктор захватывает объект |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Старый подход к погашению предупреждения: (void)expression; | |
int value = 42; | |
(void)value; | |
assert(value == 42); | |
// Объявляем макрос VENDOR_MAYBE_UNUSED, абстрагирующий | |
// разные способы добавления атрибута | |
#if __has_cpp_attribute(maybe_unused) | |
#define VENDOR_MAYBE_UNUSED [[maybe_unused]] | |
#elif __has_cpp_attribute(gnu::unused) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum class option { A, B, C }; | |
void choice(option value) | |
{ | |
switch (value) | |
{ | |
case option::A: | |
// ... | |
case option::B: // warning: unannotated fall-through between | |
// switch labels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Все макросы должны иметь префикс, вместо VENDOR подставьте | |
// короткое название компании или организации | |
#if __has_cpp_attribute(fallthrough) | |
#define VENDOR_FALLTHROUGH [[fallthrough]] | |
#elif __has_cpp_attribute(clang::fallthrough) | |
#define VENDOR_FALLTHROUGH [[clang::fallthrough]] | |
#else | |
#define VENDOR_FALLTHROUGH | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Все макросы должны иметь префикс, вместо VENDOR подставьте | |
// короткое название компании или организации | |
#if __has_cpp_attribute(nodiscard) | |
#define VENDOR_NODISCARD [[nodiscard]] | |
#elif __has_cpp_attribute(gnu::warn_unused_result) | |
#define VENDOR_NODISCARD [[gnu::warn_unused_result]] | |
#else | |
#define VENDOR_NODISCARD | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class [[nodiscard]] error_code { /* ... */ }; | |
error_code bar(); | |
void foo() | |
{ | |
// warning: ignoring return value of function declared | |
// with warn_unused_result attribute | |
bar(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int [[nodiscard]] foo() { /* ... */ } | |
void bar() | |
{ | |
// warning: ignoring return value of function declared | |
// with warn_unused_result attribute | |
foo(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __has_cpp_attribute | |
// Если компилятор не поддерживает __has_cpp_attribute, то всегда сообщаем, что атрибута нет. | |
#define __has_cpp_attribute(name) 0 | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Language: Cpp | |
# BasedOnStyle: WebKit | |
AccessModifierOffset: -4 | |
AlignAfterOpenBracket: DontAlign | |
AlignConsecutiveAssignments: false | |
AlignConsecutiveDeclarations: false | |
AlignEscapedNewlinesLeft: false | |
AlignOperands: false | |
AlignTrailingComments: false |