jiridanek commented on code in PR #397: URL: https://github.com/apache/qpid-proton/pull/397#discussion_r1172626808
########## c/include/proton/annotations.h: ########## @@ -0,0 +1,93 @@ +#ifndef PROTON_ANNOTATIONS_H +#define PROTON_ANNOTATIONS_H 1 + +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @cond INTERNAL + * + * Compiler specific mechanisms for annotating functions and function parameters. + * + * SAL (MSVC) documentation: + * https://learn.microsoft.com/en-us/cpp/c-runtime-library/sal-annotations?view=msvc-170 + * https://learn.microsoft.com/en-us/cpp/code-quality/understanding-sal?view=msvc-170&viewFallbackFrom=vs-2019 + * https://learn.microsoft.com/en-us/cpp/code-quality/annotating-function-parameters-and-return-values?view=msvc-170 + * GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html + * Clang documentation: https://clang.llvm.org/docs/AttributeReference.html + * Clang Analyzer documentation: https://clang-analyzer.llvm.org/annotations.html + * + * Example usage for the implemented annotation macros: + * + * std::string stringPrintf(PN_PRINTF_FORMAT const char* format, ...) + * PN_PRINTF_FORMAT_ATTR(1, 2); + * + * PN_NODISCARD std::unique_lock<Mutex> make_unique_lock( + * Mutex& mutex, Args&&... args) { ... } + * + */ + +// compiler specific attribute translation +// msvc should come first, so if clang is in msvc mode it gets the right defines + +// warn format placeholders + +// NOTE: this will only do checking in msvc with versions that support /analyze Review Comment: It only seems to check when one actually _uses_ `/analyze`, using the highest tier of latest visual studio does not show any warnings from this without that option. Neither `/W4` helps any. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
