net+util: fix build with gcc-7

Introduce an NDN_CXX_FALLTHROUGH macro to simplify
annotating switch cases that fall through.

Update code-style to recommend using NDN_CXX_FALLTHROUGH.

Change-Id: I80e4ff8d16a09f6ec9343f0480bc57ae0fcd1be4
diff --git a/src/util/backports-optional.hpp b/src/util/backports-optional.hpp
index 29862b1..8f1f498 100644
--- a/src/util/backports-optional.hpp
+++ b/src/util/backports-optional.hpp
@@ -42,17 +42,15 @@
 #ifndef NDN_UTIL_BACKPORTS_OPTIONAL_HPP
 #define NDN_UTIL_BACKPORTS_OPTIONAL_HPP
 
-#include "../common.hpp"
+#include "backports.hpp"
 
-#ifdef __has_include
-#  if (__cplusplus > 201402L) && __has_include(<optional>)
-#    include <optional>
-#    define NDN_CXX_HAVE_STD_OPTIONAL
-#  elif (__cplusplus > 201103L) && __has_include(<experimental/optional>)
-#    include <experimental/optional>
-#    if __cpp_lib_experimental_optional >= 201411
-#      define NDN_CXX_HAVE_EXPERIMENTAL_OPTIONAL
-#    endif
+#if (__cplusplus > 201402L) && NDN_CXX_HAS_INCLUDE(<optional>)
+#  include <optional>
+#  define NDN_CXX_HAVE_STD_OPTIONAL
+#elif (__cplusplus > 201103L) && NDN_CXX_HAS_INCLUDE(<experimental/optional>)
+#  include <experimental/optional>
+#  if __cpp_lib_experimental_optional >= 201411
+#    define NDN_CXX_HAVE_EXPERIMENTAL_OPTIONAL
 #  endif
 #endif
 
diff --git a/src/util/backports-ostream-joiner.hpp b/src/util/backports-ostream-joiner.hpp
index 24a161c..75d53dd 100644
--- a/src/util/backports-ostream-joiner.hpp
+++ b/src/util/backports-ostream-joiner.hpp
@@ -27,16 +27,12 @@
 #ifndef NDN_UTIL_BACKPORTS_OSTREAM_JOINER_HPP
 #define NDN_UTIL_BACKPORTS_OSTREAM_JOINER_HPP
 
-#include "../common.hpp"
+#include "backports.hpp"
 
-#if __cplusplus >= 201402L
-#  ifdef __has_include
-#    if __has_include(<experimental/iterator>)
-#      include <experimental/iterator>
-#      if __cpp_lib_experimental_ostream_joiner >= 201411
-#        define NDN_CXX_HAVE_EXPERIMENTAL_OSTREAM_JOINER
-#      endif
-#    endif
+#if (__cplusplus >= 201402L) && NDN_CXX_HAS_INCLUDE(<experimental/iterator>)
+#  include <experimental/iterator>
+#  if __cpp_lib_experimental_ostream_joiner >= 201411
+#    define NDN_CXX_HAVE_EXPERIMENTAL_OSTREAM_JOINER
 #  endif
 #endif
 
diff --git a/src/util/backports.hpp b/src/util/backports.hpp
index 1d0a92a..df1d775 100644
--- a/src/util/backports.hpp
+++ b/src/util/backports.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2015-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
@@ -28,6 +28,30 @@
 #include <boost/lexical_cast.hpp>
 #endif
 
+#ifdef __has_cpp_attribute
+#  define NDN_CXX_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
+#else
+#  define NDN_CXX_HAS_CPP_ATTRIBUTE(x) 0
+#endif
+
+#ifdef __has_include
+#  define NDN_CXX_HAS_INCLUDE(x) __has_include(x)
+#else
+#  define NDN_CXX_HAS_INCLUDE(x) 0
+#endif
+
+#if NDN_CXX_HAS_CPP_ATTRIBUTE(fallthrough)
+#  define NDN_CXX_FALLTHROUGH [[fallthrough]]
+#elif NDN_CXX_HAS_CPP_ATTRIBUTE(clang::fallthrough)
+#  define NDN_CXX_FALLTHROUGH [[clang::fallthrough]]
+#elif NDN_CXX_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
+#  define NDN_CXX_FALLTHROUGH [[gnu::fallthrough]]
+#elif defined(__GNUC__) && (__GNUC__ >= 7)
+#  define NDN_CXX_FALLTHROUGH __attribute__((fallthrough))
+#else
+#  define NDN_CXX_FALLTHROUGH ((void)0)
+#endif
+
 namespace ndn {
 
 #if __cpp_lib_make_unique >= 201304