[v2,2/7] printversion: Fix unused variable
Commit Message
clang complains:
debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable]
ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
^
../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF'
const char *const apba__ __asm ("argp_program_bug_address")
^
This is as expected: it's used by argp via the
"argp_program_bug_address" name, which is not visible on the C level.
Add __attribute__ ((used)) to make sure that the compiler emits it.
While at it, fix debuginfod not printing the bug report address.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
lib/printversion.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
@@ -39,11 +39,14 @@ void print_version (FILE *stream, struct argp_state *state);
argp_program_bug_address, in all programs. argp.h declares these
variables as non-const (which is correct in general). But we can
do better, it is not going to change. So we want to move them into
- the .rodata section. Define macros to do the trick. */
+ the .rodata section. Define macros to do the trick. The default
+ linkage for consts in C++ is internal, so declare them extern. */
#define ARGP_PROGRAM_VERSION_HOOK_DEF \
void (*const apvh) (FILE *, struct argp_state *) \
__asm ("argp_program_version_hook")
#define ARGP_PROGRAM_BUG_ADDRESS_DEF \
- const char *const apba__ __asm ("argp_program_bug_address")
+ extern const char *const apba__; \
+ const char *const apba__ __asm ("argp_program_bug_address") \
+ __attribute__ ((used))
#endif // PRINTVERSION_H