5 ms·
> portable > #define _GNU_SOURCE If it's portable, what's the point of defining _GNU_SOURCE? Honest question.
by sandov 7y ago
> portable
> #define _GNU_SOURCE
If it's portable, what's the point of defining _GNU_SOURCE? Honest question.
- saagarjha 7y agoI’m not sure why they aren’t using the SYS_* constants either.
- jagrsw 7y agoYup, it'd make it (also using SYS_exit instead of SYS_exit_group) compilable under various *BSD OSes. Doesn't work for some reason under NetBSD due to some linking problem producing invalid binary for the platform. $ gcc -nostartfiles a.c -o a -Wl,--entry=_start -static $ ./a -bash: ./a: cannot execute binary file: Exec format error $ file a a: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped\ But the final binary is impressively small, and it seem to contain all relevant code (body of _start and syscall funcs) $ strip -s a; ls -l a -rwxr-xr-x 1 user users 2688 Jan 5 07:53 a Works under FreeBSD though: $ clang -nostartfiles a.c -o a -static $ ./a Hello world! $ strip -s a; ls -l a -rwxr-xr-x 1 user user 9216 Jan 5 07:59 a
- deleted 7y ago[deleted]
- jagrsw 7y agoIt's 'portable' as originally stated, across various Linux CPU archs. _GNU_SOURCE is requested by man 2 syscall. Interestingly it mentions it appeared in 4BSD, so possibly it might work (maybe with some changes) under other Unixy platforms.