{"id":201,"date":"2008-12-14T04:18:17","date_gmt":"2008-12-14T08:18:17","guid":{"rendered":"http:\/\/www.virtualroadside.com\/blog\/?p=201"},"modified":"2009-03-13T18:47:54","modified_gmt":"2009-03-13T23:47:54","slug":"useful-gcc-only-trick-warn-if-return-value-is-unused","status":"publish","type":"post","link":"https:\/\/www.virtualroadside.com\/blog\/index.php\/2008\/12\/14\/useful-gcc-only-trick-warn-if-return-value-is-unused\/","title":{"rendered":"Useful GCC-only trick: warn if return value is unused"},"content":{"rendered":"<p>So I found this useful thing that you can add to your functions on GCC compilers&#8230; basically, you add an attribute to the end of the function definition and GCC will warn anytime that function is called and the return value isn&#8217;t used. Ubuntu 8.10 has enabled this for a *ton* of system calls, and its pretty useful (except when you&#8217;re just trying to do something without bothering with error checking). Of course if you don&#8217;t like -Wall then you won&#8217;t like this either&#8230;<\/p>\n<pre>\r\n#ifdef __GNUC__\r\n    #define WARN_IF_UNUSED __attribute__ ((warn_unused_result))\r\n#else\r\n    #define WARN_IF_UNUSED\r\n#endif\r\n\r\nint some_function() WARN_IF_UNUSED;\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>So I found this useful thing that you can add to your functions on GCC compilers&#8230; basically, you add an attribute to the end of the function definition and GCC will warn anytime that function is called and the return value isn&#8217;t used. Ubuntu 8.10 has enabled this for a *ton* of system calls, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[],"_links":{"self":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/201"}],"collection":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=201"}],"version-history":[{"count":6,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/201\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/201\/revisions\/231"}],"wp:attachment":[{"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtualroadside.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}