diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..e4a3e38 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/spdlog_console", + "${workspaceFolder}/spdlog_file", + "${workspaceFolder}/spdlog_udp" + ], + "defines": [], + "compilerPath": "/usr/bin/g++", + "cStandard": "c11", + "cppStandard": "c++14", + "configurationProvider": "vector-of-bool.cmake-tools", + "compileCommands": "${workspaceFolder}/build/compile_commands.json" + } + ], + "version": 4 +} diff --git a/.vscode/checks.json b/.vscode/checks.json new file mode 100644 index 0000000..c4daba5 --- /dev/null +++ b/.vscode/checks.json @@ -0,0 +1 @@ +{"enabled":true,"categories":{"abseil":{"enabled":false,"issues":{"abseil-duration-addition":false,"abseil-duration-comparison":false,"abseil-duration-conversion-cast":false,"abseil-duration-division":false,"abseil-duration-factory-float":false,"abseil-duration-factory-scale":false,"abseil-duration-subtraction":false,"abseil-duration-unnecessary-conversion":false,"abseil-faster-strsplit-delimiter":false,"abseil-no-internal-dependencies":false,"abseil-no-namespace":false,"abseil-redundant-strcat-calls":false,"abseil-str-cat-append":false,"abseil-string-find-startswith":false,"abseil-string-find-str-contains":false,"abseil-time-comparison":false,"abseil-time-subtraction":false,"abseil-upgrade-duration-conversions":false}},"android":{"enabled":false,"issues":{"android-cloexec-accept":false,"android-cloexec-accept4":true,"android-cloexec-creat":true,"android-cloexec-dup":true,"android-cloexec-epoll-create":true,"android-cloexec-epoll-create1":true,"android-cloexec-fopen":true,"android-cloexec-inotify-init":true,"android-cloexec-inotify-init1":true,"android-cloexec-memfd-create":true,"android-cloexec-open":true,"android-cloexec-pipe":true,"android-cloexec-pipe2":true,"android-cloexec-socket":true,"android-comparison-in-temp-failure-retry":true}},"boost":{"enabled":false,"issues":{"boost-use-to-string":true}},"bugprone":{"enabled":true,"issues":{"bugprone-argument-comment":true,"bugprone-assert-side-effect":true,"bugprone-bad-signal-to-kill-thread":true,"bugprone-bool-pointer-implicit-conversion":true,"bugprone-branch-clone":true,"bugprone-copy-constructor-init":true,"bugprone-dangling-handle":true,"bugprone-dynamic-static-initializers":true,"bugprone-exception-escape":true,"bugprone-fold-init-type":true,"bugprone-forward-declaration-namespace":true,"bugprone-forwarding-reference-overload":true,"bugprone-inaccurate-erase":true,"bugprone-incorrect-roundings":true,"bugprone-infinite-loop":true,"bugprone-integer-division":true,"bugprone-lambda-function-name":true,"bugprone-macro-parentheses":true,"bugprone-macro-repeated-side-effects":true,"bugprone-misplaced-operator-in-strlen-in-alloc":true,"bugprone-misplaced-pointer-arithmetic-in-alloc":true,"bugprone-misplaced-widening-cast":true,"bugprone-move-forwarding-reference":true,"bugprone-multiple-statement-macro":true,"bugprone-narrowing-conversions":true,"bugprone-no-escape":true,"bugprone-not-null-terminated-result":true,"bugprone-parent-virtual-call":true,"bugprone-posix-return":true,"bugprone-reserved-identifier":true,"bugprone-signed-char-misuse":true,"bugprone-sizeof-container":true,"bugprone-sizeof-expression":true,"bugprone-spuriously-wake-up-functions":true,"bugprone-string-constructor":true,"bugprone-string-integer-assignment":true,"bugprone-string-literal-with-embedded-nul":true,"bugprone-suspicious-enum-usage":true,"bugprone-suspicious-include":true,"bugprone-suspicious-memset-usage":true,"bugprone-suspicious-missing-comma":true,"bugprone-suspicious-semicolon":true,"bugprone-suspicious-string-compare":true,"bugprone-swapped-arguments":true,"bugprone-terminating-continue":true,"bugprone-throw-keyword-missing":true,"bugprone-too-small-loop-variable":true,"bugprone-undefined-memory-manipulation":true,"bugprone-undelegated-constructor":true,"bugprone-unhandled-self-assignment":true,"bugprone-unused-raii":true,"bugprone-unused-return-value":true,"bugprone-use-after-move":true,"bugprone-virtual-near-miss":true}},"cert":{"enabled":true,"issues":{"cert-con36-c":true,"cert-con54-cpp":true,"cert-dcl03-c":true,"cert-dcl16-c":true,"cert-dcl21-cpp":true,"cert-dcl37-c":true,"cert-dcl50-cpp":true,"cert-dcl51-cpp":true,"cert-dcl54-cpp":true,"cert-dcl58-cpp":true,"cert-dcl59-cpp":true,"cert-env33-c":true,"cert-err09-cpp":true,"cert-err34-c":true,"cert-err52-cpp":true,"cert-err58-cpp":true,"cert-err60-cpp":true,"cert-err61-cpp":true,"cert-fio38-c":true,"cert-flp30-c":true,"cert-mem57-cpp":true,"cert-msc30-c":true,"cert-msc32-c":true,"cert-msc50-cpp":true,"cert-msc51-cpp":true,"cert-oop11-cpp":true,"cert-oop54-cpp":true,"cert-oop57-cpp":true,"cert-oop58-cpp":true,"cert-pos44-c":true,"cert-str34-c":true}},"clang":{"enabled":true,"issues":{"clang-analyzer-apiModeling.StdCLibraryFunctions":true,"clang-analyzer-apiModeling.TrustNonnull":true,"clang-analyzer-apiModeling.google.GTest":true,"clang-analyzer-apiModeling.llvm.CastValue":true,"clang-analyzer-apiModeling.llvm.ReturnValue":true,"clang-analyzer-core.CallAndMessage":true,"clang-analyzer-core.CallAndMessageModeling":true,"clang-analyzer-core.DivideZero":true,"clang-analyzer-core.DynamicTypePropagation":true,"clang-analyzer-core.NonNullParamChecker":true,"clang-analyzer-core.NonnilStringConstants":true,"clang-analyzer-core.NullDereference":true,"clang-analyzer-core.StackAddrEscapeBase":true,"clang-analyzer-core.StackAddressEscape":true,"clang-analyzer-core.UndefinedBinaryOperatorResult":true,"clang-analyzer-core.VLASize":true,"clang-analyzer-core.builtin.BuiltinFunctions":true,"clang-analyzer-core.builtin.NoReturnFunctions":true,"clang-analyzer-core.uninitialized.ArraySubscript":true,"clang-analyzer-core.uninitialized.Assign":true,"clang-analyzer-core.uninitialized.Branch":true,"clang-analyzer-core.uninitialized.CapturedBlockVariable":true,"clang-analyzer-core.uninitialized.UndefReturn":true,"clang-analyzer-cplusplus.InnerPointer":true,"clang-analyzer-cplusplus.Move":true,"clang-analyzer-cplusplus.NewDelete":true,"clang-analyzer-cplusplus.NewDeleteLeaks":true,"clang-analyzer-cplusplus.PlacementNew":true,"clang-analyzer-cplusplus.PureVirtualCall":true,"clang-analyzer-cplusplus.SelfAssignment":true,"clang-analyzer-cplusplus.SmartPtrModeling":true,"clang-analyzer-cplusplus.VirtualCallModeling":true,"clang-analyzer-deadcode.DeadStores":true,"clang-analyzer-fuchsia.HandleChecker":true,"clang-analyzer-nullability.NullPassedToNonnull":true,"clang-analyzer-nullability.NullReturnedFromNonnull":true,"clang-analyzer-nullability.NullabilityBase":true,"clang-analyzer-nullability.NullableDereferenced":true,"clang-analyzer-nullability.NullablePassedToNonnull":true,"clang-analyzer-nullability.NullableReturnedFromNonnull":true,"clang-analyzer-optin.cplusplus.UninitializedObject":true,"clang-analyzer-optin.cplusplus.VirtualCall":true,"clang-analyzer-optin.mpi.MPI-Checker":true,"clang-analyzer-optin.osx.OSObjectCStyleCast":true,"clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker":true,"clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker":true,"clang-analyzer-optin.performance.GCDAntipattern":true,"clang-analyzer-optin.performance.Padding":true,"clang-analyzer-optin.portability.UnixAPI":true,"clang-analyzer-osx.API":true,"clang-analyzer-osx.MIG":true,"clang-analyzer-osx.NSOrCFErrorDerefChecker":true,"clang-analyzer-osx.NumberObjectConversion":true,"clang-analyzer-osx.OSObjectRetainCount":true,"clang-analyzer-osx.ObjCProperty":true,"clang-analyzer-osx.SecKeychainAPI":true,"clang-analyzer-osx.cocoa.AtSync":true,"clang-analyzer-osx.cocoa.AutoreleaseWrite":true,"clang-analyzer-osx.cocoa.ClassRelease":true,"clang-analyzer-osx.cocoa.Dealloc":true,"clang-analyzer-osx.cocoa.IncompatibleMethodTypes":true,"clang-analyzer-osx.cocoa.Loops":true,"clang-analyzer-osx.cocoa.MissingSuperCall":true,"clang-analyzer-osx.cocoa.NSAutoreleasePool":true,"clang-analyzer-osx.cocoa.NSError":true,"clang-analyzer-osx.cocoa.NilArg":true,"clang-analyzer-osx.cocoa.NonNilReturnValue":true,"clang-analyzer-osx.cocoa.ObjCGenerics":true,"clang-analyzer-osx.cocoa.RetainCount":true,"clang-analyzer-osx.cocoa.RetainCountBase":true,"clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak":true,"clang-analyzer-osx.cocoa.SelfInit":true,"clang-analyzer-osx.cocoa.SuperDealloc":true,"clang-analyzer-osx.cocoa.UnusedIvars":true,"clang-analyzer-osx.cocoa.VariadicMethodTypes":true,"clang-analyzer-osx.coreFoundation.CFError":true,"clang-analyzer-osx.coreFoundation.CFNumber":true,"clang-analyzer-osx.coreFoundation.CFRetainRelease":true,"clang-analyzer-osx.coreFoundation.containers.OutOfBounds":true,"clang-analyzer-osx.coreFoundation.containers.PointerSizedValues":true,"clang-analyzer-security.FloatLoopCounter":true,"clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling":true,"clang-analyzer-security.insecureAPI.SecuritySyntaxChecker":true,"clang-analyzer-security.insecureAPI.UncheckedReturn":true,"clang-analyzer-security.insecureAPI.bcmp":true,"clang-analyzer-security.insecureAPI.bcopy":true,"clang-analyzer-security.insecureAPI.bzero":true,"clang-analyzer-security.insecureAPI.decodeValueOfObjCType":true,"clang-analyzer-security.insecureAPI.getpw":true,"clang-analyzer-security.insecureAPI.gets":true,"clang-analyzer-security.insecureAPI.mkstemp":true,"clang-analyzer-security.insecureAPI.mktemp":true,"clang-analyzer-security.insecureAPI.rand":true,"clang-analyzer-security.insecureAPI.strcpy":true,"clang-analyzer-security.insecureAPI.vfork":true,"clang-analyzer-unix.API":true,"clang-analyzer-unix.DynamicMemoryModeling":true,"clang-analyzer-unix.Malloc":true,"clang-analyzer-unix.MallocSizeof":true,"clang-analyzer-unix.MismatchedDeallocator":true,"clang-analyzer-unix.Vfork":true,"clang-analyzer-unix.cstring.BadSizeArg":true,"clang-analyzer-unix.cstring.CStringModeling":true,"clang-analyzer-unix.cstring.NullArg":true,"clang-analyzer-valist.CopyToSelf":true,"clang-analyzer-valist.Uninitialized":true,"clang-analyzer-valist.Unterminated":true,"clang-analyzer-valist.ValistBase":true,"clang-analyzer-webkit.NoUncountedMemberChecker":true,"clang-analyzer-webkit.RefCntblBaseVirtualDtor":true,"clang-diagnostic-missing-field-initializers":false}},"cppcoreguidelines":{"enabled":true,"issues":{"cppcoreguidelines-avoid-c-arrays":true,"cppcoreguidelines-avoid-goto":true,"cppcoreguidelines-avoid-magic-numbers":true,"cppcoreguidelines-avoid-non-const-global-variables":true,"cppcoreguidelines-c-copy-assignment-signature":true,"cppcoreguidelines-explicit-virtual-functions":true,"cppcoreguidelines-init-variables":true,"cppcoreguidelines-interfaces-global-init":true,"cppcoreguidelines-macro-usage":true,"cppcoreguidelines-narrowing-conversions":true,"cppcoreguidelines-no-malloc":true,"cppcoreguidelines-non-private-member-variables-in-classes":true,"cppcoreguidelines-owning-memory":true,"cppcoreguidelines-pro-bounds-array-to-pointer-decay":false,"cppcoreguidelines-pro-bounds-constant-array-index":false,"cppcoreguidelines-pro-bounds-pointer-arithmetic":true,"cppcoreguidelines-pro-type-const-cast":true,"cppcoreguidelines-pro-type-cstyle-cast":true,"cppcoreguidelines-pro-type-member-init":true,"cppcoreguidelines-pro-type-reinterpret-cast":true,"cppcoreguidelines-pro-type-static-cast-downcast":true,"cppcoreguidelines-pro-type-union-access":true,"cppcoreguidelines-pro-type-vararg":false,"cppcoreguidelines-slicing":true,"cppcoreguidelines-special-member-functions":true}},"darwin":{"enabled":true,"issues":{"darwin-avoid-spinlock":true,"darwin-dispatch-once-nonstatic":true}},"fuchsia":{"enabled":false,"issues":{"fuchsia-default-arguments-calls":false,"fuchsia-default-arguments-declarations":false,"fuchsia-header-anon-namespaces":false,"fuchsia-multiple-inheritance":false,"fuchsia-overloaded-operator":false,"fuchsia-statically-constructed-objects":false,"fuchsia-trailing-return":false,"fuchsia-virtual-inheritance":false}},"google":{"enabled":false,"issues":{"google-build-explicit-make-pair":false,"google-build-namespaces":false,"google-build-using-namespace":false,"google-default-arguments":false,"google-explicit-constructor":false,"google-global-names-in-headers":false,"google-objc-avoid-nsobject-new":false,"google-objc-avoid-throwing-exception":false,"google-objc-function-naming":false,"google-objc-global-variable-declaration":false,"google-readability-avoid-underscore-in-googletest-name":false,"google-readability-braces-around-statements":false,"google-readability-casting":false,"google-readability-function-size":false,"google-readability-namespace-comments":false,"google-readability-todo":false,"google-runtime-int":false,"google-runtime-operator":false,"google-runtime-references":false,"google-upgrade-googletest-case":false}},"hicpp":{"enabled":false,"issues":{"hicpp-avoid-c-arrays":false,"hicpp-avoid-goto":false,"hicpp-braces-around-statements":false,"hicpp-deprecated-headers":false,"hicpp-exception-baseclass":false,"hicpp-explicit-conversions":false,"hicpp-function-size":false,"hicpp-invalid-access-moved":false,"hicpp-member-init":false,"hicpp-move-const-arg":false,"hicpp-multiway-paths-covered":false,"hicpp-named-parameter":false,"hicpp-new-delete-operators":false,"hicpp-no-array-decay":false,"hicpp-no-assembler":false,"hicpp-no-malloc":false,"hicpp-noexcept-move":false,"hicpp-signed-bitwise":false,"hicpp-special-member-functions":false,"hicpp-static-assert":false,"hicpp-undelegated-constructor":false,"hicpp-uppercase-literal-suffix":false,"hicpp-use-auto":false,"hicpp-use-emplace":false,"hicpp-use-equals-default":false,"hicpp-use-equals-delete":false,"hicpp-use-noexcept":false,"hicpp-use-nullptr":false,"hicpp-use-override":false,"hicpp-vararg":false}},"linuxkernel":{"enabled":false,"issues":{"linuxkernel-must-check-errs":true}},"llvm":{"enabled":false,"issues":{"llvm-else-after-return":false,"llvm-header-guard":false,"llvm-include-order":false,"llvm-namespace-comment":false,"llvm-prefer-isa-or-dyn-cast-in-conditionals":false,"llvm-prefer-register-over-unsigned":false,"llvm-qualified-auto":false,"llvm-twine-local":false}},"llvmlibc":{"enabled":false,"issues":{"llvmlibc-callee-namespace":false,"llvmlibc-implementation-in-namespace":false,"llvmlibc-restrict-system-libc-headers":false}},"misc":{"enabled":false,"issues":{"misc-definitions-in-headers":false,"misc-misplaced-const":false,"misc-new-delete-overloads":false,"misc-no-recursion":false,"misc-non-copyable-objects":false,"misc-non-private-member-variables-in-classes":false,"misc-redundant-expression":false,"misc-static-assert":false,"misc-throw-by-value-catch-by-reference":false,"misc-unconventional-assign-operator":false,"misc-uniqueptr-reset-release":false,"misc-unused-alias-decls":false,"misc-unused-parameters":false,"misc-unused-using-decls":false}},"modernize":{"enabled":false,"issues":{"modernize-avoid-bind":false,"modernize-avoid-c-arrays":false,"modernize-concat-nested-namespaces":false,"modernize-deprecated-headers":false,"modernize-deprecated-ios-base-aliases":false,"modernize-loop-convert":false,"modernize-make-shared":false,"modernize-make-unique":false,"modernize-pass-by-value":false,"modernize-raw-string-literal":false,"modernize-redundant-void-arg":false,"modernize-replace-auto-ptr":false,"modernize-replace-disallow-copy-and-assign-macro":false,"modernize-replace-random-shuffle":false,"modernize-return-braced-init-list":false,"modernize-shrink-to-fit":false,"modernize-unary-static-assert":false,"modernize-use-auto":false,"modernize-use-bool-literals":false,"modernize-use-default-member-init":false,"modernize-use-emplace":false,"modernize-use-equals-default":false,"modernize-use-equals-delete":false,"modernize-use-nodiscard":false,"modernize-use-noexcept":false,"modernize-use-nullptr":false,"modernize-use-override":false,"modernize-use-trailing-return-type":false,"modernize-use-transparent-functors":false,"modernize-use-uncaught-exceptions":false,"modernize-use-using":false}},"mpi":{"enabled":false,"issues":{"mpi-buffer-deref":true,"mpi-type-mismatch":true}},"objc":{"enabled":false,"issues":{"objc-avoid-nserror-init":true,"objc-dealloc-in-category":true,"objc-forbidden-subclassing":true,"objc-missing-hash":true,"objc-nsinvocation-argument-lifetime":true,"objc-property-declaration":true,"objc-super-self":true}},"openmp":{"enabled":false,"issues":{"openmp-exception-escape":true,"openmp-use-default-none":true}},"performance":{"enabled":true,"issues":{"performance-faster-string-find":true,"performance-for-range-copy":true,"performance-implicit-conversion-in-loop":true,"performance-inefficient-algorithm":true,"performance-inefficient-string-concatenation":true,"performance-inefficient-vector-operation":true,"performance-move-const-arg":true,"performance-move-constructor-init":true,"performance-no-automatic-move":true,"performance-noexcept-move-constructor":true,"performance-trivially-destructible":true,"performance-type-promotion-in-math-fn":true,"performance-unnecessary-copy-initialization":true,"performance-unnecessary-value-param":true}},"portability":{"enabled":true,"issues":{"portability-restrict-system-includes":true,"portability-simd-intrinsics":true}},"readability":{"enabled":true,"issues":{"readability-avoid-const-params-in-decls":true,"readability-braces-around-statements":true,"readability-const-return-type":true,"readability-container-size-empty":true,"readability-convert-member-functions-to-static":true,"readability-delete-null-pointer":true,"readability-deleted-default":true,"readability-else-after-return":true,"readability-function-size":true,"readability-identifier-naming":true,"readability-implicit-bool-conversion":true,"readability-inconsistent-declaration-parameter-name":true,"readability-isolate-declaration":true,"readability-magic-numbers":true,"readability-make-member-function-const":true,"readability-misleading-indentation":true,"readability-misplaced-array-index":true,"readability-named-parameter":true,"readability-non-const-parameter":true,"readability-qualified-auto":true,"readability-redundant-access-specifiers":true,"readability-redundant-control-flow":true,"readability-redundant-declaration":true,"readability-redundant-function-ptr-dereference":true,"readability-redundant-member-init":true,"readability-redundant-preprocessor":true,"readability-redundant-smartptr-get":true,"readability-redundant-string-cstr":true,"readability-redundant-string-init":true,"readability-simplify-boolean-expr":true,"readability-simplify-subscript-expr":true,"readability-static-accessed-through-instance":true,"readability-static-definition-in-anonymous-namespace":true,"readability-string-compare":true,"readability-uniqueptr-delete-release":true,"readability-uppercase-literal-suffix":true,"readability-use-anyofallof":true}},"zircon":{"enabled":false,"issues":{"zircon-temporary-objects":true}}}} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 94941ce..e13998f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "C_Cpp.default.configurationProvider": "go2sh.cmake-integration" + "C_Cpp.default.configurationProvider": "go2sh.cmake-integration", + "clangtidy.buildPath": "${workspaceFolder}/build", + "clangtidy.sourcePath": "${workspaceFolder}/spdlog_udp", + "clangtidy.checksPath": "${workspaceFolder}/.vscode", } \ No newline at end of file diff --git a/spdlog_console/console.cpp b/spdlog_console/console.cpp index 88e449e..1e2fbfe 100644 --- a/spdlog_console/console.cpp +++ b/spdlog_console/console.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/spdlog_file/file.cpp b/spdlog_file/file.cpp index 7b42f67..48b7d7b 100644 --- a/spdlog_file/file.cpp +++ b/spdlog_file/file.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/spdlog_udp/udp.cpp b/spdlog_udp/udp.cpp index 07cf5d2..6743e91 100644 --- a/spdlog_udp/udp.cpp +++ b/spdlog_udp/udp.cpp @@ -88,7 +88,7 @@ int main(int argc, char **argv) { int logLevel = spdlog::level::trace; std::string ipAddr {"127.0.0.1"}; - int port = 9000; + uint16_t port = 9000; int c; while ((c = getopt(argc, argv, "l:i:p:?")) != EOF) { @@ -101,7 +101,7 @@ int main(int argc, char **argv) ipAddr = optarg; break; case 's': - port = std::stoi(optarg); + port = static_cast(std::stoi(optarg)); break; case '?': usage(); diff --git a/spdlog_udp/udp_client.h b/spdlog_udp/udp_client.h index 5822f5c..e006e15 100644 --- a/spdlog_udp/udp_client.h +++ b/spdlog_udp/udp_client.h @@ -27,7 +27,7 @@ class udp_client struct sockaddr_in sockAddr_; public: - bool init(const std::string &host, int port) + bool init(const std::string &host, uint16_t port) { socket_ = socket(PF_INET, SOCK_DGRAM, 0); if (socket_ < 0) @@ -40,7 +40,7 @@ class udp_client sockAddr_.sin_port = htons(port); inet_aton(host.c_str(), &sockAddr_.sin_addr); - memset(sockAddr_.sin_zero, 0x00, 8); + memset(sockAddr_.sin_zero, 0x00, sizeof(sockAddr_.sin_zero)); return true; } @@ -72,8 +72,8 @@ class udp_client // On error close the connection and throw. void send(const char *data, size_t n_bytes) { - size_t toslen = 0; - size_t tolen = sizeof(struct sockaddr); + ssize_t toslen = 0; + socklen_t tolen = sizeof(struct sockaddr); if (( toslen = sendto(socket_, data, n_bytes, 0, (struct sockaddr *)&sockAddr_, tolen)) == -1) { throw_spdlog_ex("write(2) failed", errno); diff --git a/spdlog_udp/udp_client_windows.h b/spdlog_udp/udp_client_windows.h index 0d81c67..239095a 100644 --- a/spdlog_udp/udp_client_windows.h +++ b/spdlog_udp/udp_client_windows.h @@ -8,6 +8,7 @@ #include #include +#ifdef _WIN32 #include #include #include @@ -65,7 +66,7 @@ class udp_client return socket_ != INVALID_SOCKET; } - bool init(const std::string &host, int port) + bool init(const std::string &host, uint16_t port) { // initialize winsock if needed if (!winsock_initialized_()) @@ -111,4 +112,6 @@ class udp_client } }; } // namespace details -} // namespace spdlog \ No newline at end of file +} // namespace spdlog + +#endif \ No newline at end of file diff --git a/spdlog_udp/udp_sink.h b/spdlog_udp/udp_sink.h index c46bb90..5b87945 100644 --- a/spdlog_udp/udp_sink.h +++ b/spdlog_udp/udp_sink.h @@ -32,9 +32,9 @@ namespace sinks { struct udp_sink_config { std::string server_host; - int server_port; + uint16_t server_port; - udp_sink_config(std::string host, int port) + udp_sink_config(std::string host, uint16_t port) : server_host{std::move(host)} , server_port{port} {}