Live data from Hacker News

The most useful GCC options and extensions

antoarts.com

11–20 of 22 posts

Re: The most useful GCC options and extensions

#11
post #10

A few others I use are -Wsign-compare and -Wformat-nonliteral. Sign compare warns on possible bugs/vulnerabilities due to comparing signed and unsigned values. Using nonliteral formats can lead to vulnerabilities (such as the famous attacks on FTP servers http://seclists.org/bugtraq/1999/Sep/328 )

-Wall includes -Wsign-compare

You must be a C++ user -- I (a C guy) immediately thought "what? No, that's in -Wextra, not -Wall", checked the man page to confirm, and sure enough, it differs (-Wall includes sign-compare when compiling C++, but not C).

Re: The most useful GCC options and extensions

#14
post #9

My favorite is the "weak" attribute. http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html Makes separate compilation for languages that compile to C much easier.

My favorite would be "pure" -- it's perfect for saying "this function pointer, which calls an assembly function, doesn't muck with any of your data structures, so you don't have to reload every single pointer after it returns".

But unfortunately, since it was basically written only for libc purposes, it doesn't work on function pointers, so it's useless for this purpose.

Re: The most useful GCC options and extensions

#18
post #12

Is it me, or is this statement from the article wrong: "All warnings can be enabled with -w." man g++ says: "-w Inhibit all warning messages." Inhibit means to prevent (not to enable).

It is case sensitive; -W enables more warnings, not -w, which as you noticed suppresses them.

Re: The most useful GCC options and extensions

#20
post #19
post #17

Earlier quoted context omitted.

How is that nice? And I can't find this quote in the article.

It's in the sidebar. Just amused me is all.

The quotes are randomly chosen from a database of my favorite ~50 quotes, so it isn't related to the article, though
Post reply on HN