added missing dependencies to fix failing unistr/ tests
[gnulib.git] / build-aux / link-warning.h
1 /* A C macro for emitting link time warnings.
2    Copyright (C) 1995, 1997, 2000, 2002-2003, 2007, 2009-2010 Free Software
3    Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify it
6    under the terms of the GNU Lesser General Public License as published
7    by the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 /* GL_LINK_WARNING("literal string") arranges to emit the literal string as
19    a linker warning on most glibc systems.
20    We use a linker warning rather than a preprocessor warning, because
21    #warning cannot be used inside macros.  */
22 #ifndef GL_LINK_WARNING
23   /* This works on platforms with GNU ld and ELF object format.
24      Testing __GLIBC__ is sufficient for asserting that GNU ld is in use.
25      Testing __ELF__ guarantees the ELF object format.
26      Testing __GNUC__ is necessary for the compound expression syntax.  */
27 # if defined __GLIBC__ && defined __ELF__ && defined __GNUC__
28 #  define GL_LINK_WARNING(message) \
29      GL_LINK_WARNING1 (__FILE__, __LINE__, message)
30 #  define GL_LINK_WARNING1(file, line, message) \
31      GL_LINK_WARNING2 (file, line, message)  /* macroexpand file and line */
32 #  define GL_LINK_WARNING2(file, line, message) \
33      GL_LINK_WARNING3 (file ":" #line ": warning: " message)
34 #  define GL_LINK_WARNING3(message) \
35      ({ static const char warning[sizeof (message)]             \
36           __attribute__ ((__unused__,                           \
37                           __section__ (".gnu.warning"),         \
38                           __aligned__ (1)))                     \
39           = message "\n";                                       \
40         (void)0;                                                \
41      })
42 # else
43 #  define GL_LINK_WARNING(message) ((void) 0)
44 # endif
45 #endif