Skip to content

Commit

Permalink
Add BUILD_MESSAGE() macro
Browse files Browse the repository at this point in the history
This commit introduces the BUILD_MESSAGE() macro. It uses _Pragma("message"),
with compilers that support that, to output a warning-like compile-time message
without blocking the compilation.

Used by next commit.

Signed-off-by: Daniele Di Proietto <[email protected]>
Acked-by: Jarno Rajahalme <[email protected]>
  • Loading branch information
ddiproietto authored and Jarno Rajahalme committed Aug 29, 2014
1 parent 30f4d87 commit aa8ea22
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ AC_ARG_VAR(KARCH, [Kernel Architecture String])
AC_SUBST(KARCH)
OVS_CHECK_LINUX
OVS_CHECK_DPDK
OVS_CHECK_PRAGMA_MESSAGE

AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(datapath/Makefile)
Expand Down
10 changes: 10 additions & 0 deletions lib/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,14 @@
#define OVS_PREFETCH_WRITE(addr)
#endif

/* Output a message (not an error) while compiling without failing the
* compilation process */
#if HAVE_PRAGMA_MESSAGE
#define DO_PRAGMA(x) _Pragma(#x)
#define BUILD_MESSAGE(x) \
DO_PRAGMA(message(x))
#else
#define BUILD_MESSAGE(x)
#endif

#endif /* compiler.h */
9 changes: 9 additions & 0 deletions m4/openvswitch.m4
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,12 @@ dnl OVS_CHECK_INCLUDE_NEXT
AC_DEFUN([OVS_CHECK_INCLUDE_NEXT],
[AC_REQUIRE([gl_CHECK_NEXT_HEADERS])
gl_CHECK_NEXT_HEADERS([$1])])

dnl OVS_CHECK_PRAGMA_MESSAGE
AC_DEFUN([OVS_CHECK_PRAGMA_MESSAGE],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[_Pragma("message(\"Checking for pragma message\")")
]])],
[AC_DEFINE(HAVE_PRAGMA_MESSAGE,1,[Define if compiler supports #pragma
message directive])])
])

0 comments on commit aa8ea22

Please sign in to comment.