Hi,
I am stuck with a very strange error and was wondering if anyone can help. I have been given the task of updating a USB stack used in our firmware: elm-chan.org/.../00index_e.html
I downloaded the latest source, linked it in to the poroject in place of the previous version and am now getting an error from the line:
typedef unsigned long DWORD;
Looking at the previous version of the code this line was:
typedef unsigned long FFDWORD;
Sure enough, changing the name to anything except DWORD seems to work like a charm, but will require me to track down the rather large number of instances of DWORD and change them to something else. More importantly,
should work!
I am using keil uVision V3.31 and am stuck using that version as the code doesn't compile correctly on later versions.
Does anyone have any ideas? Is this a Keil 3.31 bug, or have I just not set something correctly?
Any help is much appreciated.
You say you're getting an error, but unfortunately I don't see you giving details of that error.
It's likely going to be a re-definition. What is it previously (you may have to look through a pre-processor listing to find this)? if it is the same (or comparable) you could maybe consider commenting out the one currently giving the error.
Whoops, sorry yes I am getting two errors from this line, though they are generic C errors:
..\FF12A\SRC\INTEGER.H(33): error C25: syntax error near 'unsigned' ..\FF12A\SRC\INTEGER.H(33): error C25: syntax error near ')'
..\FF12A\SRC\INTEGER.H(33): error C25: syntax error near ')'
This message says there's an unwanted ')' in that line. But in the source you look at, there is no ')' at all. What that tells us is that there is evidently a definition like
#define DWORD (unsigned long) // or something like the DBYTE library macro...
somewhere in your source. That's where that ')' came from, and it's the cause of this conflict. You really cannot have multiple definitions of the same type visible in the same source code, nor re-use a #defined name as a typedef name.
I would lay the blame for this at the library author's feet. Type names like DWORD should never be used by third-party libraries, nor your own in-house source code. They're practically guaranteed to run into a definition conflict like this. C++ has name spaces to avoid this; in C you really have to apply name prefixes.