diff --git a/.clang-format b/.clang-format index 2f402d514..9fe8681f7 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ -# please use clang-format version 13 or later +# please use clang-format version 16 or later Standard: c++17 AccessModifierOffset: -8 @@ -52,8 +52,8 @@ ContinuationIndentWidth: 8 Cpp11BracedListStyle: true DerivePointerAlignment: false DisableFormat: false -FixNamespaceComments: false -ForEachMacros: +FixNamespaceComments: true +ForEachMacros: - 'json_object_foreach' - 'json_object_foreach_safe' - 'json_array_foreach' diff --git a/.github/actions/run-clang-format/action.yaml b/.github/actions/run-clang-format/action.yaml index ff7465182..3442c259d 100644 --- a/.github/actions/run-clang-format/action.yaml +++ b/.github/actions/run-clang-format/action.yaml @@ -28,7 +28,7 @@ runs: echo ::group::Install Dependencies eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - echo "/home/linuxbrew/.linuxbrew/opt/clang-format@13/bin" >> $GITHUB_PATH + echo "/home/linuxbrew/.linuxbrew/opt/clang-format@16/bin" >> $GITHUB_PATH brew install --quiet zsh echo ::endgroup:: @@ -53,11 +53,11 @@ runs: } if (( ${changes[(I)(*.c|*.h|*.cpp|*.hpp|*.m|*.mm)]} )) { - print ::group::Install clang-format-13 - brew install --quiet obsproject/tools/clang-format@13 + print ::group::Install clang-format-16 + brew install --quiet obsproject/tools/clang-format@16 print ::endgroup:: - print ::group::Run clang-format-13 + print ::group::Run clang-format-16 ./build-aux/run-clang-format --fail-${{ inputs.failCondition }} --check print ::endgroup:: } diff --git a/UI/properties-view.cpp b/UI/properties-view.cpp index d0ff72a9b..ab8f8b043 100644 --- a/UI/properties-view.cpp +++ b/UI/properties-view.cpp @@ -83,7 +83,7 @@ struct common_frame_rate { media_frames_per_second fps; }; -} +} // namespace Q_DECLARE_METATYPE(frame_rate_tag); Q_DECLARE_METATYPE(media_frames_per_second); @@ -919,7 +919,7 @@ template<> struct default_delete { void operator()(obs_data_item_t *item) { obs_data_item_release(&item); } }; -} +} // namespace std template static double make_epsilon(T val) { diff --git a/UI/win-update/updater/manifest.hpp b/UI/win-update/updater/manifest.hpp index dce7a7d74..ce6f7d2ce 100644 --- a/UI/win-update/updater/manifest.hpp +++ b/UI/win-update/updater/manifest.hpp @@ -91,4 +91,4 @@ struct PatchResponse { }; using PatchesResponse = std::vector; -} +} // namespace updater diff --git a/UI/win-update/updater/updater.cpp b/UI/win-update/updater/updater.cpp index b8a65f88c..bf8207b26 100644 --- a/UI/win-update/updater/updater.cpp +++ b/UI/win-update/updater/updater.cpp @@ -276,7 +276,7 @@ template<> struct hash { string_view((const char *)value.data(), value.size())); } }; -} +} // namespace std enum state_t { STATE_INVALID, diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index dfc1aaf63..16b910468 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -126,7 +126,7 @@ template struct SignalContainer { OBSRef ref; vector> handlers; }; -} +} // namespace extern volatile long insideEventLoop; diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 61f64dd10..46015d2f7 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -4863,7 +4863,7 @@ template<> struct hash { return h2; } }; -} +} // namespace std bool OBSBasicSettings::ScanDuplicateHotkeys(QFormLayout *layout) { diff --git a/build-aux/.run-format.zsh b/build-aux/.run-format.zsh index ea9167f96..be4687290 100755 --- a/build-aux/.run-format.zsh +++ b/build-aux/.run-format.zsh @@ -29,24 +29,24 @@ invoke_formatter() { case ${1} { clang) - if (( ${+commands[clang-format-13]} )) { - local formatter=clang-format-13 + if (( ${+commands[clang-format-16]} )) { + local formatter=clang-format-16 } elif (( ${+commands[clang-format]} )) { local formatter=clang-format } else { - log_error "No viable clang-format version found (required 13.0.1)" + log_error "No viable clang-format version found (required 16.0.5)" exit 2 } local -a formatter_version=($(${formatter} --version)) - if ! is-at-least 13.0.1 ${formatter_version[-1]}; then - log_error "clang-format is not version 13.0.1 or above (found ${formatter_version[-1]}." + if ! is-at-least 16.0.5 ${formatter_version[-1]}; then + log_error "clang-format is not version 16.0.5 or above (found ${formatter_version[-1]}." exit 2 fi - if ! is-at-least ${formatter_version[-1]} 13.0.1; then - log_error "clang-format is more recent than version 13.0.1 (found ${formatter_version[-1]})." + if ! is-at-least ${formatter_version[-1]} 16.0.5; then + log_error "clang-format is more recent than version 16.0.5 (found ${formatter_version[-1]})." exit 2 fi diff --git a/libobs/obs-module.h b/libobs/obs-module.h index 7b1776580..87941320e 100644 --- a/libobs/obs-module.h +++ b/libobs/obs-module.h @@ -73,16 +73,22 @@ bool obs_module_load(void) */ /** Required: Declares a libobs module. */ -#define OBS_DECLARE_MODULE() \ - static obs_module_t *obs_module_pointer; \ - MODULE_EXPORT void obs_module_set_pointer(obs_module_t *module); \ - void obs_module_set_pointer(obs_module_t *module) \ - { \ - obs_module_pointer = module; \ - } \ - obs_module_t *obs_current_module(void) { return obs_module_pointer; } \ - MODULE_EXPORT uint32_t obs_module_ver(void); \ - uint32_t obs_module_ver(void) { return LIBOBS_API_VER; } +#define OBS_DECLARE_MODULE() \ + static obs_module_t *obs_module_pointer; \ + MODULE_EXPORT void obs_module_set_pointer(obs_module_t *module); \ + void obs_module_set_pointer(obs_module_t *module) \ + { \ + obs_module_pointer = module; \ + } \ + obs_module_t *obs_current_module(void) \ + { \ + return obs_module_pointer; \ + } \ + MODULE_EXPORT uint32_t obs_module_ver(void); \ + uint32_t obs_module_ver(void) \ + { \ + return LIBOBS_API_VER; \ + } /** * Required: Called when the module is loaded. Use this function to load all @@ -166,7 +172,10 @@ MODULE_EXTERN obs_module_t *obs_current_module(void); */ #define OBS_MODULE_AUTHOR(name) \ MODULE_EXPORT const char *obs_module_author(void); \ - const char *obs_module_author(void) { return name; } + const char *obs_module_author(void) \ + { \ + return name; \ + } /** Optional: Returns the full name of the module */ MODULE_EXPORT const char *obs_module_name(void); diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 6e0c22843..0cf9b5652 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -366,8 +366,7 @@ obs_source_create_internal(const char *id, const char *name, const char *uuid, * * XXX: Fix design flaws with filters */ if (info->type == OBS_SOURCE_TYPE_FILTER) - private - = true; + private = true; } source->mute_unmute_key = OBS_INVALID_HOTKEY_PAIR_ID; diff --git a/libobs/obs.hpp b/libobs/obs.hpp index 4446f0ecc..9b046ca7f 100644 --- a/libobs/obs.hpp +++ b/libobs/obs.hpp @@ -136,8 +136,7 @@ class OBSRef : public OBSRefAutoRelease { return *this; } - struct TakeOwnership { - }; + struct TakeOwnership {}; inline OBSRef(T val_, TakeOwnership) : OBSRefAutoRelease::OBSRefAutoRelease(val_) { @@ -180,8 +179,7 @@ class OBSSafeRef : public OBSRefAutoRelease { return *this; } - struct TakeOwnership { - }; + struct TakeOwnership {}; inline OBSSafeRef(T val_, TakeOwnership) : OBSRefAutoRelease::OBSRefAutoRelease(val_) { diff --git a/libobs/util/profiler.hpp b/libobs/util/profiler.hpp index aa75a8e8d..dbfbdfac3 100644 --- a/libobs/util/profiler.hpp +++ b/libobs/util/profiler.hpp @@ -42,7 +42,10 @@ struct ScopeProfiler { #define ScopeProfiler_Name(x) ScopeProfiler_NameConcat(x, __LINE__) #endif -#define ProfileScope(x) \ - ScopeProfiler ScopeProfiler_Name(SCOPE_PROFILE) { x } +#define ProfileScope(x) \ + ScopeProfiler ScopeProfiler_Name(SCOPE_PROFILE) \ + { \ + x \ + } #endif diff --git a/plugins/aja/aja-card-manager.cpp b/plugins/aja/aja-card-manager.cpp index 552012474..a54777c9d 100644 --- a/plugins/aja/aja-card-manager.cpp +++ b/plugins/aja/aja-card-manager.cpp @@ -618,4 +618,4 @@ const CardEntries::iterator CardManager::end() return mCardEntries.end(); } -} // aja +} // namespace aja diff --git a/plugins/aja/aja-card-manager.hpp b/plugins/aja/aja-card-manager.hpp index 1809428fd..53d5bb6d6 100644 --- a/plugins/aja/aja-card-manager.hpp +++ b/plugins/aja/aja-card-manager.hpp @@ -103,4 +103,4 @@ private: mutable std::mutex mMutex; }; -} // aja +} // namespace aja diff --git a/plugins/aja/aja-common.cpp b/plugins/aja/aja-common.cpp index b4a77c035..f65ae481d 100644 --- a/plugins/aja/aja-common.cpp +++ b/plugins/aja/aja-common.cpp @@ -1183,4 +1183,4 @@ std::vector MultiViewCards() return {DEVICE_ID_IOX3}; } -} // aja +} // namespace aja diff --git a/plugins/aja/aja-common.hpp b/plugins/aja/aja-common.hpp index 37201fb78..caa9dd87d 100644 --- a/plugins/aja/aja-common.hpp +++ b/plugins/aja/aja-common.hpp @@ -110,4 +110,4 @@ extern VPIDStandard DetermineVPIDStandard(IOSelection io, NTV2VideoFormat vf, SDITransport4K t4k); extern std::vector MultiViewCards(); -} // aja +} // namespace aja diff --git a/plugins/aja/aja-presets.cpp b/plugins/aja/aja-presets.cpp index 94fbac383..4010eb122 100644 --- a/plugins/aja/aja-presets.cpp +++ b/plugins/aja/aja-presets.cpp @@ -1836,4 +1836,4 @@ bool RoutingConfigurator::FindFirstPreset(ConnectionKind kind, NTV2DeviceID id, return false; } -} // aja +} // namespace aja diff --git a/plugins/aja/aja-presets.hpp b/plugins/aja/aja-presets.hpp index 37a5f78df..1277abdd5 100644 --- a/plugins/aja/aja-presets.hpp +++ b/plugins/aja/aja-presets.hpp @@ -46,4 +46,4 @@ private: RoutingPresetMap m_presets; }; -} // aja +} // namespace aja diff --git a/plugins/aja/aja-routing.cpp b/plugins/aja/aja-routing.cpp index 14686656f..57c5edc31 100644 --- a/plugins/aja/aja-routing.cpp +++ b/plugins/aja/aja-routing.cpp @@ -608,4 +608,4 @@ void Routing::LogRoutingPreset(const RoutingPreset &rp) } } -} // aja +} // namespace aja diff --git a/plugins/aja/aja-routing.hpp b/plugins/aja/aja-routing.hpp index ae670e691..6f452a7aa 100644 --- a/plugins/aja/aja-routing.hpp +++ b/plugins/aja/aja-routing.hpp @@ -62,4 +62,4 @@ public: static void LogRoutingPreset(const RoutingPreset &rp); }; -} // aja +} // namespace aja diff --git a/plugins/coreaudio-encoder/encoder.cpp b/plugins/coreaudio-encoder/encoder.cpp index 999e67e61..eb6dc057f 100644 --- a/plugins/coreaudio-encoder/encoder.cpp +++ b/plugins/coreaudio-encoder/encoder.cpp @@ -125,7 +125,7 @@ struct ca_encoder { }; typedef struct ca_encoder ca_encoder; -} +} // namespace namespace std { @@ -152,7 +152,7 @@ template<> struct default_delete::type> { } }; -} +} // namespace std template using cf_ptr = unique_ptr::type>; @@ -1405,8 +1405,7 @@ bool obs_module_load(void) CA_LOG(LOG_INFO, "Adding CoreAudio AAC encoder"); #endif - struct obs_encoder_info aac_info { - }; + struct obs_encoder_info aac_info {}; aac_info.id = "CoreAudio_AAC"; aac_info.type = OBS_ENCODER_AUDIO; aac_info.codec = "aac"; diff --git a/plugins/mac-avcapture/av-capture.mm b/plugins/mac-avcapture/av-capture.mm index 5e73cf300..a72487fcc 100644 --- a/plugins/mac-avcapture/av-capture.mm +++ b/plugins/mac-avcapture/av-capture.mm @@ -41,7 +41,7 @@ namespace std { } }; -} +} // namespace std #define TEXT_AVCAPTURE obs_module_text("AVCapture") #define TEXT_DEVICE obs_module_text("Device") @@ -111,7 +111,7 @@ namespace { bool video_params_valid = false; }; -} +} // namespace struct av_capture { OBSAVCaptureDelegate *delegate; @@ -303,7 +303,7 @@ namespace { } }; -} +} // namespace static av_capture_ref get_ref(obs_properties_t *props) { diff --git a/plugins/mac-avcapture/left-right.hpp b/plugins/mac-avcapture/left-right.hpp index 123f35551..aefa84f38 100644 --- a/plugins/mac-avcapture/left-right.hpp +++ b/plugins/mac-avcapture/left-right.hpp @@ -60,4 +60,4 @@ private: T data[2] = {{}, {}}; }; -} +} // namespace left_right diff --git a/plugins/mac-avcapture/scope-guard.hpp b/plugins/mac-avcapture/scope-guard.hpp index 27f5d9201..81dab6c9c 100644 --- a/plugins/mac-avcapture/scope-guard.hpp +++ b/plugins/mac-avcapture/scope-guard.hpp @@ -58,7 +58,7 @@ operator+(detail::ScopeGuardOnExit, FunctionType &&fn) std::forward(fn)); } -} +} // namespace detail } // namespace scope_guard_util diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-url.h b/plugins/obs-ffmpeg/obs-ffmpeg-url.h index 213c21a53..1f780848b 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-url.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-url.h @@ -139,5 +139,5 @@ enum type { }; } class Logger; -} +} // namespace srt_logging #endif