This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Warn once for a deprecated class, and not each instantiation
- From: Jeffrey Walton <noloader at gmail dot com>
- To: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Wed, 7 Oct 2015 16:21:19 -0400
- Subject: Warn once for a deprecated class, and not each instantiation
- Authentication-results: sourceware.org; auth=none
- Reply-to: noloader at gmail dot com
We have a C++ header-only class that needs to change due to a bug. We
marked it as deprecated:
template <class C1, class C2 = X, class C3 = Y>
struct BAD_CLASS
: ...
{
...
} __attribute__((deprecated ("BAD_CLASS will be changing in the near
future due to (1) an implementation bug and (2) an interop issue.")));
Each instantiation produces a separate, multiline warning. The
intention is to warn the user (once), and not repeatedly warn the user
(multiple times). We expect those who are mindful of warnings "get it"
the first time. For others, it does not matter how many times its
repeated because they are going to ignore it.
Is it possible to "warn once" in this situation? If so, how?
Does GCC have something Microsoft's "pragma once(...)" for warnings?
Thanks in advance.