Skip to content

Commit

Permalink
include: add _NL_NO_WARN_DEPRECATED_HEADER for suppressing warning ab…
Browse files Browse the repository at this point in the history
…out deprecated headers

Header files are part of a stable API. Warning about using deprecated
API is cumbersome, albeit often useful to force the user to migrate
away from the API.

But it also requires that the unit test disables "-Wcpp". That is
problematic on its own, because we don't want to disable any warnings.

As we only have 4 such header files, instead guard the warnings with
a

  #ifndef _NL_NO_WARN_DEPRECATED_HEADER
  • Loading branch information
thom311 committed May 6, 2024
1 parent 881a2a2 commit b7d05e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,9 @@ EXTRA_DIST += \
$(COMPILE) \
-Wall \
-Werror \
-Wno-error=cpp \
-I$(srcdir)/include \
-I$(builddir)/include \
-D_NL_NO_WARN_DEPRECATED_HEADER \
-c \
-o $@ $<

Expand Down
2 changes: 2 additions & 0 deletions include/netlink/cache-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <netlink/netlink.h>
#include <netlink/cache.h>

#ifndef _NL_NO_WARN_DEPRECATED_HEADER
#warning "You are including a deprecated header file, include <netlink/cache.h>."
#endif

#endif
2 changes: 2 additions & 0 deletions include/netlink/route/link/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <netlink/netlink.h>
#include <netlink/route/link.h>

#ifndef _NL_NO_WARN_DEPRECATED_HEADER
#warning "You are including a deprecated header file, include <netlink/route/link.h>."
#endif

#endif
2 changes: 2 additions & 0 deletions include/netlink/route/link/info-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <netlink/netlink.h>
#include <netlink/route/link.h>

#ifndef _NL_NO_WARN_DEPRECATED_HEADER
#warning "You are including a deprecated header file, include <netlink/route/link.h>."
#endif

#endif
2 changes: 2 additions & 0 deletions include/netlink/route/tc-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <netlink/msg.h>
#include <netlink/route/tc.h>

#ifndef _NL_NO_WARN_DEPRECATED_HEADER
#warning "You are including a deprecated header file, include <netlink/route/tc.h>."
#endif

#endif

0 comments on commit b7d05e5

Please sign in to comment.