Hi!
After you telling me that it works as expected for you, I tried some more test
cases. And yes, in your setup it works.
The difference is that the include file in question was placed differently.
If the included files are in the project folder, all works as expected.
If they are in the msp430/include folder, things do not work as expected. Or
maybe they do, but not as _I_ expected.
try the following:
add the lines
#include "msp430x54xx.h"
#define WDTCTL_ 0
#ifdef WDTCTL_
#warning redefinition warning expected
#define WDTCTL_ 1
#endif
right at the start of your projects "msp430xyyy.h" file and compile.
On my machine it gives
---------------------
c:/Programme/msp430/mspgcc_0812/bin/msp430-gcc -v -c -std=gnu99 -g -Os -Wall
-Wcast-align -Wcast-qual -Wimplicit -Wnested-externs -Wpointer-arith
-Wredundant-decls -Wreturn-type -Wshadow -Wstrict-
prototypes -Wswitch -Wunused -Wundef -Wunreachable-code -mmcu=msp430x5438
-Wa,-ahlms=obj/ez3.lst -I. -I../EPOS_COMMON_3 ez3.c -o obj/ez3.o
Reading specs from
c:\Programme\msp430\mspgcc_0812\bin\..\lib\gcc-lib\msp430\3.2.3\specs
Configured with: ./configure --target=msp430
--prefix=c:/work/mspgcc/sf/packaging/build/installed --disable-multilib
--disable-libc --disable-libssp --disable-intl --disable-libiberty --with-gcc
--with-gnu-ld --with-gnu-as --
with-stabs --disable-shared --disable-threads --disable-win32-registry
--disable-nls --enable-languages=c,c++
Thread model: single
gcc version 3.2.3
c:\Programme\msp430\mspgcc_0812\bin\..\lib\gcc-lib\msp430\3.2.3\cc1.exe
-lang-c -v -I. -I../EPOS_COMMON_3 -iprefix
c:/Programme/msp430/mspgcc_0812/bin/..\lib/gcc-lib/msp430\3.2.3\ -D__GNUC__=3 -
D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=3 -D__GXX_ABI_VERSION=102 -DMSP430
-D__MSP430__ -D__MSP430 -D__OPTIMIZE_SIZE__ -D__OPTIMIZE__ -D__STDC_HOSTED__=1
-DMSP430
_HAS_HW_MUL -D__MSP430_5438__ -D__MSP430X2__ -DMSP430_HAS_HWMUL
-D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D__INT_MAX__=32767 ez3.c
-quiet -dumpbase ez3.c -
mmcu=msp430x5438 -g -Os -Wall -Wcast-align -Wcast-qual -Wimplicit
-Wnested-externs -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow
-Wstrict-prototypes -Wswitch -Wunused -Wundef -
Wunreachable-code -std=gnu99 -version -o
C:\DOKUME~1\Grossi\LOKALE~1\Temp/ccuoFwwf.s
GNU CPP version 3.2.3 (cpplib) (GNU assembler syntax)
GNU C version 3.2.3 (msp430)
compiled by GNU C version 3.4.5 (mingw-vista special r3).
ignoring nonexistent directory
"c:/Programme/msp430/mspgcc_0812/msp430/sys-include"
ignoring nonexistent directory
"c:/work/mspgcc/sf/packaging/build/installed/include"
ignoring nonexistent directory
"c:/work/mspgcc/sf/packaging/build/installed/lib/gcc-lib/msp430/3.2.3/include"
ignoring nonexistent directory
"c:/work/mspgcc/sf/packaging/build/installed/lib/gcc-lib/msp430/3.2.3/../../../../msp430/sys-include"
ignoring nonexistent directory
"c:/work/mspgcc/sf/packaging/build/installed/lib/gcc-lib/msp430/3.2.3/../../../../msp430/include"
#include "..." search starts here:
#include <...> search starts here:
.
../EPOS_COMMON_3
c:/Programme/msp430/mspgcc_0812/lib/gcc-lib/msp430/3.2.3/include
c:/Programme/msp430/mspgcc_0812/msp430/include
End of search list.
In file included from ../EPOS_COMMON_3/system54xx.h:27,
from system.h:5,
from ez3.c:11:
c:/Programme/msp430/mspgcc_0812/msp430/include/msp430x54xx.h:6:2: warning:
#warning redefinition warning expected
c:\Programme\msp430\mspgcc_0812\bin\..\lib\gcc-lib\msp430\3.2.3\..\..\..\..\msp430\bin\as.exe
--traditional-format -mmcu=msp430x5438 -ahlms=obj/ez3.lst -o obj/ez3.o
C:\DOKUME~1\Grossi\LOKALE~1
\Temp/ccuoFwwf.s
262 16 8 286 11e obj/ez3.o
------------------------------
you see, the manually placed warning is printed, but the redefinition is not
detected.
It looks like the redefinition warning is suppressed when (msp)gcc includes a
file from its global include path, but not when the included file is in the
project folder itself or one of the folders you added with the -I option.
Since all global include files do an #undef before redefining things, I'm not
sure whether this is an intentional behaviour. And even if it is, it makes
working on the global include files more difficult - and a real pain if
you're not aware of this.
As a side effect I noticed that mspgcc does not add dependencies to global
include files into its generated dependency file, so if you change one of them,
make will not remake the object files which include it. Once
again, maybe intended (it definitely speeds up dependency checking) but still a
source of problems if you are working on the global includes.
So question is: is there an option to disable this, at least as long as one is
working on the global includes.
I just found a workaround: by manually adding the global include folder to the
search path (option -Ic:/Programme/msp430/mspgcc_0812/msp430/include), warnings
do come as expected. And I got a couple more
warnings than expected.There are some more undiscovered redefinitions in the
global includes: in string.h, memset is defined twice (identical), the
structured register declaration in wdt_a.h complains about a missing
semicolon and there was another double-definition in my own
unified_clock_system.h that slipped detection. All of them not harmful but
still undetected before.
JMGross
----- Ursprüngliche Nachricht -----
Von: Przemek Klosowski
An: [email protected]
Gesendet am: 22 Jan 2010 23:23:40
Betreff: Re: [Mspgcc-users] Possible preprocessor bug
Jens-Michael,
I didn't understand the problem. Perhaps you could explain it by providing
an example of a minimal set of .h files that demonstrate your problem by
showing what CPP gets vs. what you expected.
I for instance made three files, a.h, b.h and c.h:
a.h:
#define WDTCTL0 1
b.h:
#define WDTCTL0 2
c,h:
#include "a.h"
#include "b.h"
and my 3.2.3 mspgcc seems to do the right thing:
[...]