{"id":1677,"date":"2022-08-30T15:18:31","date_gmt":"2022-08-30T15:18:31","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/gcc-compiler-error-with-d-option-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:18:31","modified_gmt":"2022-08-30T15:18:31","slug":"gcc-compiler-error-with-d-option-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/gcc-compiler-error-with-d-option-collection-of-common-programming-errors\/","title":{"rendered":"gcc compiler error with -D option-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;ve written a makefile that compiles multiple files. when executing a line like this :<\/p>\n<pre><code>g++ -c -Wall -U DEBUG -U FILE -U HighPriority -U OnlyCUDA -U CUDA -U THREAD_NUM -U SIZE -U InputFileName -D FILE -D SIZE=32 -D THREAD_NUM=4 -D CUDA -D InputFileName=input\/In32.txt  ..\/src\/lib\/Globals.cpp -o Globals.o\n<\/code><\/pre>\n<p>It generates a huge list of errors:<\/p>\n<pre><code>In file included from \/usr\/include\/wchar.h:36:0,\n                 from \/usr\/include\/c++\/4.6\/cwchar:46,\n                 from \/usr\/include\/c++\/4.6\/bits\/postypes.h:42,\n                 from \/usr\/include\/c++\/4.6\/iosfwd:42,\n                 from \/usr\/include\/c++\/4.6\/ios:39,\n                 from \/usr\/include\/c++\/4.6\/istream:40,\n                 from \/usr\/include\/c++\/4.6\/sstream:39,\n                 from \/usr\/include\/c++\/4.6\/complex:47,\n                 from ..\/src\/lib\/..\/inlcude\/Globals.h:3,\n                 from ..\/src\/lib\/Globals.cpp:1:\n\/usr\/include\/stdio.h:48:25: error: expected unqualified-id before numeric constant\n<\/code><\/pre>\n<p>but when I remove -D FILE it compiles just fine. what is this about ??<\/p>\n<p>EDIT1: the same #define FILE works fine when I use codeblocks for example. why so ??<\/p>\n<ol>\n<li>\n<p><code>FILE<\/code> is already used in C as a file pointer object (see the <code>fopen(3)<\/code> manpage).<\/p>\n<p>You will need to choose a different name for that constant.<\/p>\n<p>The actual error is caused by the declaration of functions like <code>fopen()<\/code>:<\/p>\n<pre><code>FILE *fopen(const char *restrict filename, const char *restrict mode);\n<\/code><\/pre>\n<p>being turned into:<\/p>\n<pre><code>*fopen(const char *restrict filename, const char *restrict mode);\n<\/code><\/pre>\n<p>because you defined <code>FILE<\/code> to <em>nothing<\/em>.<\/p>\n<p><strong>EDIT<\/strong> Actually it&#8217;s probably causing an issue in the declaration of <code>FILE<\/code> itself, and not the <code>fopen()<\/code> et al functions:<\/p>\n<pre><code>typedef struct __sFILE {\n    ...\n} FILE;\n<\/code><\/pre>\n<p>Where <code>FILE<\/code> is replaced with <em>nothing<\/em>.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-27 12:27:10. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve written a makefile that compiles multiple files. when executing a line like this : g++ -c -Wall -U DEBUG -U FILE -U HighPriority -U OnlyCUDA -U CUDA -U THREAD_NUM -U SIZE -U InputFileName -D FILE -D SIZE=32 -D THREAD_NUM=4 -D CUDA -D InputFileName=input\/In32.txt ..\/src\/lib\/Globals.cpp -o Globals.o It generates a huge list of errors: In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1677","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1677"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1677\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}