{"id":35,"date":"2008-04-16T23:28:00","date_gmt":"2008-04-17T06:28:00","guid":{"rendered":"http:\/\/samueldotj.com\/blog\/?p=35"},"modified":"2008-04-16T23:28:00","modified_gmt":"2008-04-17T06:28:00","slug":"leading-underscores-in-c","status":"publish","type":"post","link":"https:\/\/samueldotj.com\/blog\/leading-underscores-in-c\/","title":{"rendered":"Leading underscores in C"},"content":{"rendered":"<p>C compilers were prepending an underscore to all the symbols (function, variable names). I read from somewhere this is to avoid name collision with other language libraries. This convention was started with UNIX. When UNIX was written in C to use the existing assembly libraries, C symbols were added with a leading underscore by compilers and linkers.<\/p>\n<p>Currently there is no need for this unless otherwise if you want to use old library. So most of the new C compilers are not adding leading underscores; however it also depends on the platform and object file. For example, Linux a.out GCC does such prepending, while Linux ELF GCC does not.    <\/p>\n<p>To explicitly tell the GCC compiler to not to use leading underscore you can use <span>\u2013fno-leading-underscore <\/span>option.<\/p>\n<p>Note: FORTRAN was adding both leading and trailing underscores to avoid name collision to avoid naming collision with C. <span> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C compilers were prepending an underscore to all the symbols (function, variable names). I read from somewhere this is to avoid name collision with other language libraries. This convention was started with UNIX. When UNIX was written in C to use the existing assembly libraries, C symbols were added with a leading underscore by compilers [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5],"tags":[],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-c","category-programming"],"_links":{"self":[{"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":0,"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"wp:attachment":[{"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samueldotj.com\/blog\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}