Warning: [#47-D] incompatible redefinition of macro "<name> (declared at line 36 of <file>)10/11/2016 SRC\file.h:35: warning: [#47-D] incompatible redefinition of macro <name> (declared at line 36 of <file>) Reason: You are trying to redefine an already defined macro. It can be defined also in the file you are including.
Example 1: <file: headerfile.h> #define MACRO_NAME 0x01u; /* "MACRO_NAME" is defined here */ <file: file.c> #include "headerfile.h" /* we include header file which defines MACRO_NAME */ #define MACRO_NAME 0x03u; /* We are defining MACRO_NAME again */ Example 2: <file: headerfile1.h> #define MACRO_NAME 0x01u; /* "MACRO_NAME" is defined here */ <file: headerfile2.h> #define MACRO_NAME 0x04u; /* "MACRO_NAME" is also defined here */ <file: file.c> /* Wrong situation */ #include "headerfile1.h" /* Here the MACRO_NAME is first defined */ #include "headerfile2.h" /* Here the MACRO_NAME is defined again */ Problems: If the code, which follows the includes of both header files, would in its different parts (like different functions) expect different values of MACRO_NAME, than it will be a problem, because compiler will assign the last one it found (from headerfile2.h in example 2). For example: one of the functions described in file.c would be written, expecting value of MACRO_NAME as defined in headerfile1.h; another functions from file.c would be written, such that MACRO_NAME from headerfile2.h was expected. This would lead to situation were the first function mentioned, will get the wrong value.
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
AuthorWarnings are important! Archives
May 2017
Categories |