浏览代码

rtmp-services: Remove macro-based constant usage

Macros make the code you see different from the code the compiler sees.
Modern C renders traditional uses of macros for constants and utility
functions unnecessary. Macros should only be used when there is no
other solution available.
PatTheMav 2 年之前
父节点
当前提交
1172629492

+ 1 - 1
plugins/rtmp-services/CMakeLists.txt

@@ -35,7 +35,7 @@ target_sources(
           rtmp-services-main.c
           rtmp-format-ver.h)
 
-target_compile_definitions(rtmp-services PRIVATE RTMP_SERVICES_URL="${RTMP_SERVICES_URL}"
+target_compile_definitions(rtmp-services PRIVATE SERVICES_URL="${RTMP_SERVICES_URL}"
                                                  $<$<BOOL:${ENABLE_SERVICE_UPDATES}>:ENABLE_SERVICE_UPDATES>)
 
 target_link_libraries(rtmp-services PRIVATE OBS::libobs OBS::file-updater jansson::jansson)

+ 1 - 1
plugins/rtmp-services/cmake/legacy.cmake

@@ -28,7 +28,7 @@ target_sources(
           rtmp-services-main.c
           rtmp-format-ver.h)
 
-target_compile_definitions(rtmp-services PRIVATE RTMP_SERVICES_URL="${RTMP_SERVICES_URL}"
+target_compile_definitions(rtmp-services PRIVATE SERVICES_URL="${RTMP_SERVICES_URL}"
                                                  $<$<BOOL:${ENABLE_SERVICE_UPDATES}>:ENABLE_SERVICE_UPDATES>)
 
 target_include_directories(rtmp-services PRIVATE ${CMAKE_BINARY_DIR}/config)

+ 1 - 1
plugins/rtmp-services/rtmp-format-ver.h

@@ -1,3 +1,3 @@
 #pragma once
 
-#define RTMP_SERVICES_FORMAT_VERSION 4
+static const int RTMP_SERVICES_FORMAT_VERSION = 4;

+ 2 - 2
plugins/rtmp-services/rtmp-services-main.c

@@ -17,8 +17,8 @@ MODULE_EXPORT const char *obs_module_description(void)
 	return "OBS core RTMP services";
 }
 
-#define RTMP_SERVICES_LOG_STR "[rtmp-services plugin] "
-#define RTMP_SERVICES_VER_STR "rtmp-services plugin (libobs " OBS_VERSION ")"
+static const char *RTMP_SERVICES_LOG_STR = "[rtmp-services plugin] ";
+static const char *RTMP_SERVICES_URL = (const char *)SERVICES_URL;
 
 extern struct obs_service_info rtmp_common_service;
 extern struct obs_service_info rtmp_custom_service;