You are not logged in.
#include <stdio.h>
#include <unistd.h>
int main()
{
printf("%p\n", sbrk(0));
}
Code above is compiled without any warning with this,
gcc -Wall -Wextra -Wpedantic brk.c
However, adding -std=c11 to it, the compiler starts to complain,
brk.c: In function ‘main’:
brk.c:6:20: warning: implicit declaration of function ‘sbrk’ [-Wimplicit-function-declaration]
6 | printf("%p\n", sbrk(0));
| ^~~~
brk.c:6:14: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int’ [-Wformat=]
6 | printf("%p\n", sbrk(0));
| ~^ ~~~~~~~
| | |
| | int
| void *
| %d
I understand without -std option, gcc defaults to gnu11. But I don't see how does affect the function declaration lookup.
Is this intended?
Offline
But I don't see how does affect the function declaration lookup.
gnu11 supports more things in the standard C library than POSIX/ISO. It is to be expected that things that work with gnu11 won't necessarily also work with c11.
On a technical level, the standard you choose has an effect on which macros will be defined in /usr/include/features.h. You will see that these macros are then also used to guard the definition of `sbrk` in /usr/include/unistd.h.
Offline