{"id":715,"date":"2010-04-06T20:35:48","date_gmt":"2010-04-07T02:35:48","guid":{"rendered":"http:\/\/thesmithfam.org\/blog\/?p=715"},"modified":"2019-08-12T07:15:31","modified_gmt":"2019-08-12T13:15:31","slug":"reminder-dont-hard-code-it","status":"publish","type":"post","link":"https:\/\/thesmithfam.org\/blog\/2010\/04\/06\/reminder-dont-hard-code-it\/","title":{"rendered":"Reminder: Don&#8217;t Hard Code It"},"content":{"rendered":"<p>Today&#8217;s reminder comes from the &#8220;magic number&#8221; department, where we remind you to never hard-code a magic number in your software. For example, the value for <strong>ETIMEDOUT<\/strong> on Linux can vary depending on your C library. <strong>glibc<\/strong>, for example, defines it as 110, but <strong>uClibc<\/strong> defines it as 145. This tends to matter when you are using a return value from, for example, libusb, at an important branching point in your software. Of course, this whole exercise is hypothetical. I would never hard code a number like that, of course not.<\/p>\n<p><strong>The upside:<\/strong><br \/>\nThe <a href=\"http:\/\/www.libusb.org\/browser\">libusb source code<\/a> is available for the world to see.<\/p>\n<p><strong>The downside:<\/strong><br \/>\nThe <a href=\"http:\/\/libusb.sourceforge.net\/doc\/\">libusb documentation<\/a> <a href=\"http:\/\/www.google.com\/search?q=etimedout+site:libusb.sourceforge.net\">makes no mention<\/a> of <strong>ETIMEDOUT<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s reminder comes from the &#8220;magic number&#8221; department, where we remind you to never hard-code a magic number in your software. For example, the value for ETIMEDOUT on Linux can vary depending on your C library. glibc, for example, defines it as 110, but uClibc defines it as 145. This tends to matter when you [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-715","post","type-post","status-publish","format-standard","hentry","category-code-and-cruft"],"_links":{"self":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/comments?post=715"}],"version-history":[{"count":8,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/715\/revisions"}],"predecessor-version":[{"id":1521,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/715\/revisions\/1521"}],"wp:attachment":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/media?parent=715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/categories?post=715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/tags?post=715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}