summaryrefslogtreecommitdiff
path: root/lib/vty.h
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-07-12 16:23:40 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-07-13 20:29:18 +0200
commit8867927f0ea63a0a76ac75592da554da995ed9de (patch)
tree24c80703a5adced05a825e0e28a469e77a3d40c8 /lib/vty.h
parent817302b875f68005b3dddd5639dfa7a1f0c20192 (diff)
lib: vty: warn when using compatibility macros
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/vty.h')
-rw-r--r--lib/vty.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/lib/vty.h b/lib/vty.h
index b4a55180d3..5cd28c0c42 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -183,13 +183,35 @@ struct vty_arg
#define VTYNL ((vty->type == VTY_TERM) ? "\r\n" : "\n")
/* for compatibility */
-#define VTY_NEWLINE VTYNL
-#define VTY_GET_INTEGER(desc,v,str) {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_ULONG(desc,v,str) {(v)=strtoul ((str), NULL, 10);}
-#define VTY_GET_ULL(desc,v,str) {(v)=strtoull ((str), NULL, 10);}
-#define VTY_GET_IPV4_ADDRESS(desc,v,str) inet_aton ((str), &(v))
-#define VTY_GET_IPV4_PREFIX(desc,v,str) str2prefix_ipv4 ((str), &(v))
+#if defined(__ICC)
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(message __FILE__ ": " text))
+
+#elif (defined(__GNUC__) && \
+ (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \
+ (defined(__clang__) && \
+ (__clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 5)))
+#define CPP_WARN_STR(X) #X
+#define CPP_WARN(text) _Pragma(CPP_WARN_STR(GCC warning text))
+
+#else
+#define CPP_WARN(text)
+#endif
+
+#define VTY_NEWLINE VTYNL \
+ CPP_WARN("VTY_NEWLINE has been replaced with VTYNL and/or vty_outln().")
+#define VTY_GET_INTEGER(desc,v,str) {(v)=strtoul ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_INTEGER is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_INTEGER_RANGE(desc,v,str,min,max) {(v)=strtoul ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_INTEGER_RANGE is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_ULONG(desc,v,str) {(v)=strtoul ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_ULONG is no longer useful, use strtoul() or DEFPY.")
+#define VTY_GET_ULL(desc,v,str) {(v)=strtoull ((str), NULL, 10);} \
+ CPP_WARN("VTY_GET_ULL is no longer useful, use strtoull() or DEFPY.")
+#define VTY_GET_IPV4_ADDRESS(desc,v,str) inet_aton ((str), &(v)) \
+ CPP_WARN("VTY_GET_IPV4_ADDRESS is no longer useful, use inet_aton() or DEFPY.")
+#define VTY_GET_IPV4_PREFIX(desc,v,str) str2prefix_ipv4 ((str), &(v)) \
+ CPP_WARN("VTY_GET_IPV4_PREFIX is no longer useful, use str2prefix_ipv4() or DEFPY.")
/* Default time out value */
#define VTY_TIMEOUT_DEFAULT 600