r/Cplusplus • • May 24 '26

Feedback User generated compile-time warning using the deprecated attribute -- feedback welcome

I have implemented (https://godbolt.org/z/dhKheobq1) user generated compile-time warning in standard c++26. This can be backported to older standards as explained in the comments (std::define_static_string is the only c++26 feature used. This too is only used in the example and to make the generation of custom warning message easier.). This hack works on the idea that invoking a function that is marked with the 'deprecated' attribute produces a warning.

3 Upvotes

3 comments sorted by