In fact, you cannot turn off the GCC linker warning, because it is stored in a specific section of the binary library that you are communicating with. (The section is called .gnu.warning.symbol)
, , , ( libc-symbols.h):
:
#include <sys/stat.h>
int main()
{
lchmod("/path/to/whatever", 0666);
return 0;
}
:
$ gcc a.c
/tmp/cc0TGjC8.o: in function ยซ main ยป:
a.c:(.text+0xf): WARNING: lchmod is not implemented and will always fail
:
#include <sys/stat.h>
#define __make_section_unallocated(section_string) \
__asm__ (".section " section_string "\n\t.previous");
#define silent_warning(symbol) \
__make_section_unallocated (".gnu.warning." #symbol)
silent_warning(lchmod)
int main()
{
lchmod("/path/to/whatever", 0666);
return 0;
}
:
$ gcc a.c
/tmp/cc195eKj.o: in function ยซ main ยป:
a.c:(.text+0xf): WARNING:
:
#include <sys/stat.h>
#define __hide_section_warning(section_string) \
__asm__ (".section " section_string "\n.string \"\rHello world! \"\n\t.previous");
#define hide_warning(symbol) \
__hide_section_warning (".gnu.warning." #symbol)
hide_warning(lchmod)
int main()
{
lchmod("/path/to/whatever", 0666);
return 0;
}
:
$ gcc a.c
/tmp/cc195eKj.o: in function ยซ main ยป:
Hello world!
, Hello world! , .