Bug 48696 - asprintf not defined
Summary: asprintf not defined
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: App/xmodmap (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Alan Coopersmith
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-14 14:22 UTC by Dominique Leuenberger
Modified: 2012-04-30 15:50 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
#define _GNU_SOURCE (293 bytes, patch)
2012-04-14 14:22 UTC, Dominique Leuenberger
no flags Details | Splinter Review
0001-include-config.h-before-stdio.h-other-system-headers.patch (1.29 KB, patch)
2012-04-23 07:30 UTC, Alan Coopersmith
no flags Details | Splinter Review

Description Dominique Leuenberger 2012-04-14 14:22:05 UTC
Created attachment 59986 [details] [review]
#define _GNU_SOURCE

While building xmodmap 1.0.6, I ran into this build error:

gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wcast-qual -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-strict-aliasing  -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -c xmodmap.c
xmodmap.c: In function 'main':
xmodmap.c:247:5: error: implicit declaration of function 'asprintf' [-Werror=implicit-function-declaration]
xmodmap.c:247:5: warning: nested extern declaration of 'asprintf' [-Wnested-externs]
cc1: some warnings being treated as errors


As per asprintf man page:
SYNOPSIS
       #define _GNU_SOURCE         /* See feature_test_macros(7) */
       #include <stdio.h>

       int asprintf(char **strp, const char *fmt, ...);

       int vasprintf(char **strp, const char *fmt, va_list ap);


=> Adding #define _GNU_SOURCE fixes the build.
Comment 1 Alan Coopersmith 2012-04-14 14:45:46 UTC
http://patchwork.freedesktop.org/patch/9923/ submitted for review
letting autoconf pick the right #define for the platform, since not
all of X.Org's supported platforms use/require _GNU_SOURCE for that.
Comment 2 Alan Coopersmith 2012-04-17 16:47:48 UTC
Fix pushed to git master.
Comment 3 Vincent Untz 2012-04-23 01:01:28 UTC
The committed fix didn't help, I still get the same error with xmodmap 1.0.7.
Comment 4 Alan Coopersmith 2012-04-23 07:30:54 UTC
Created attachment 60482 [details] [review]
0001-include-config.h-before-stdio.h-other-system-headers.patch

Seems like something is different with your build setup then, since no other
Linux user, nor the Linux tinderboxes, are reporting any such problem.

However, I do see there could be an ordering problem, as configure now 
generates config.h to include:

/* Enable GNU extensions on systems that have them.  */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif

But xmodmap.c doesn't include config.h directly, instead gets it via
xmodmap.h which is loaded after stdio.h - the attached patch should
correct it.

I'm not going to bother pushing/releasing this until you test & confirm
first though.
Comment 5 Dominique Leuenberger 2012-04-29 14:57:41 UTC
(In reply to comment #4)
> Created attachment 60482 [details] [review] [review]
> 0001-include-config.h-before-stdio.h-other-system-headers.patch

I made a test build with this patch attached (and one more without):
- Without patch: fails (as expected)
- With patch: Build succeeds.

So from my PoV, this looks fine as a solution as well.
Comment 6 Alan Coopersmith 2012-04-30 15:50:27 UTC
Thanks, fix pushed to git master.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.