export proper syntax for GSL_SUPPRESS for new VS (#1213)

A new Visual Studio version will soon be available that deprecates the
old syntax for gsl::suppress. Customers will now get a C4875 diagnostic
on suppressions that look like `gsl::suppress(x)` urging them to use
`gsl::suppress("x")` instead.

This change updates the `GSL_SUPPRESS` macro to preprocess
GSL_SUPPRESS(x) to gsl::suppress("x") on clang and new versions of MSVC.
This commit is contained in:
Carson Radtke authored and GitHub committed 2025-10-02 08:47:16 -06:00
1 parent 494e6e988c
commit 543d0dd3fe
3 files changed
+9 -8

No files matched your search

+2 -2
View File
@@ -49,9 +49,9 @@ See [GSL.assert: Assertions](https://isocpp.github.io/CppCoreGuidelines/CppCoreG
This macro can be used to suppress a code analysis warning.
The core guidelines request tools that check for the rules to respect suppressing a rule by writing
`[[gsl::suppress(tag)]]` or `[[gsl::suppress(tag, justification: "message")]]`.
`[[gsl::suppress("tag")]]` or `[[gsl::suppress("tag", justification: "message")]]`.
Clang does not use exactly that syntax, but requires `tag` to be put in double quotes `[[gsl::suppress("tag")]]`.
Older versions of MSVC (VS 2022 and earlier) only understand `[[gsl::suppress(tag)]]` without the double quotes around `tag`.
For portable code you can use `GSL_SUPPRESS(tag)`.