How do you suppress GCC linker warnings? -
I recently went to a campaign to eliminate warnings from my code and became familiar with the GCC alert flag (E.g., -Wall
, -no-> warning to disable>
, -fdiagnostics-show-option
, etc. ). Although I did not understand how to disable (or even control) Linker Alerts The most common linker warning I was getting is the following:
LD: Warning: & lt; Some symbols & gt; & Lt; Path / to / library.a & gt; Has different visibility (default) and (hidden) & lt; Path / to / my / class.o & gt; I was getting this reason because this library I was using was created using default
visibility, while my app was hidden
Visibility I have fixed it by rebuilding the library with hidden
visibility. My question is: If I want to stop that warning? It's nothing like what I have to do now, I know how to fix it, but I'm still curious how would you suppress that particular warning - or any linker warnings in general?
Using the -fdiagnostics-show-option
for any C / C ++ / linker flag does not say where the alert comes from the way other compiler warnings.
Actually, you can not disable GCC Linker Alert, because it is a specific binary library Is stored in the section that you are linking to. (The section is called .gnu.warning. Symbol )
You can mute it, such as (it is derived from libc-symbols.h): < / P>
Without it:
#include & lt; Sys / stat.h & gt; Int main () {lchmod ("/ path / to / whatever", 0666); Return 0; }
returns:
$ gcc ac /tmp/cc0TGjC8.o: in the function «main»: ac :(. Text + 0xf): Warning: Lchmod has not been implemented and will always fail if
is unsuccessful:
#include & lt; Sys / stat.h & gt; / * We want that the .gnu.warning.SYMBOL section to be unallocated * / #define __make_section_non-section (section_string) \ __asm__ (".section" section_string "\ n \ t.previous"); / * When a reference to SYMBOL comes up, the linker will emit a warning message MSG. * / # Defin mute_word (symbol) \ __make_section_noncoken (".gnu.warning." #symbol) Mute_verning (LCMOD) main () (lchmod ("/ path / whatever", 0666); return 0;}
returns:
$ gcc ac /tmp/cc195eKj.o: in the function «main»: ac :(. Text + 0xf): Warning:
with hiding:
#include #define __hide_section_warning (section_string) \ __asm__ (".section" section_string "\ N.string \" \ rHello world! \ "\ N \ t.previous"); / * If you want to hide the output of the linker * / #define hide_warning (symbol) \ __hide_section_warning (".gnu.warning. "#symbol) hide_ Warning (lchmod) int main () {lchmod ("/ path / to / whatever", 0666); return 0;}
returns:
$ Gcc ac /tmp/cc195eKj.o: In the function «main»: Hello world!
Obviously, in that case Hello World!
So many ads or some advertisements for your amazing project.
Comments
Post a Comment