C++ Logo


Advanced search

Subject: Re: [std-proposals] Allow [[deprecated]] on call site to disable deprecated warning
From: Giuseppe D'Angelo (giuseppe.dangelo_at_[hidden])
Date: 2021-01-28 07:46:05

Il 28/01/21 12:34, Ville Voutilainen via Std-Proposals ha scritto:
> Create your own MY_DEPRECATED macro, make it expand to actual
> deprecation normally, but not in unit tests,
> compile the unit tests with -DMY_SOMETHING that disables deprecations.
> Or just add a #define into
> your unit tests.

The annoyance of these macros is their scope.

In the unit test for class A, you may want to test its deprecated
functions, and not get a warning for those.

But if testing class A requires also using class B, which you're not
"testing", you may still want to get deprecation warnings for B. So
you'd end up with an explosion of different deprecation macros "per each
thing you want to test".

Or, solve this at the buildsystem level, like compile under
-Wno-error=deprecated, filter _some_ warnings out from the compiler logs
(depending the unit test you're compiling; above, filter out A's related
warnings), and if there are still deprecation warnings, cause a build
failure. Sounds fun.

My 2 c,

Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups