I am using MC9S08DZ60.h of CodeWarrior to create a Visual Studio project. I am getting:

error C2054: expected '(' to follow '_PTDD'`.

MC9S08DZ60.h is a header file for microcontroller MC9S08DZ60 (from Freescale Semiconductor):

typedef union {
    byte Byte;
    struct {
        byte PTDDD0  :1;  /* Data Direction for Port D Bit 0 */
        byte PTDDD1  :1;  /* Data Direction for Port D Bit 1 */
        byte PTDDD2  :1;  /* Data Direction for Port D Bit 2 */
        byte PTDDD3  :1;  /* Data Direction for Port D Bit 3 */
        byte PTDDD4  :1;  /* Data Direction for Port D Bit 4 */
        byte PTDDD5  :1;  /* Data Direction for Port D Bit 5 */
        byte PTDDD6  :1;  /* Data Direction for Port D Bit 6 */
        byte PTDDD7  :1;  /* Data Direction for Port D Bit 7 */
    } Bits;
} PTDDDSTR;
#ifndef MXVDEV //sri
extern volatile PTDDDSTR _PTDDD @0x00000007;
#else
PTDDDSTR _PTDDD;
#endif
#define PTDDD             _PTDDD.Byte
#define PTDDD_PTDDD0      _PTDDD.Bits.PTDDD0
#define PTDDD_PTDDD1      _PTDDD.Bits.PTDDD1
#define PTDDD_PTDDD2      _PTDDD.Bits.PTDDD2
#define PTDDD_PTDDD3      _PTDDD.Bits.PTDDD3
#define PTDDD_PTDDD4      _PTDDD.Bits.PTDDD4
#define PTDDD_PTDDD5      _PTDDD.Bits.PTDDD5
#define PTDDD_PTDDD6      _PTDDD.Bits.PTDDD6
#define PTDDD_PTDDD7      _PTDDD.Bits.PTDDD7
3

There are 3 answers

0
Some programmer dude On

If MXVDEV is not defined by the preprocessor, you will have the declaration

extern volatile PTDDDSTR _PTDDD @0x00000007;

The @0x00000007 part is probably an extension of the CodeWarrior compiler, and it's not in the Visual Studio compiler, which means you will get an error.

2
Lundin On

The Codewarrior register maps don't follow the C standard. The @ operator used to allocate a variable at a particular address is not standard, nor are bit-fields of any type other than int.

The reason they are using the non-standard syntax is because they want to generate debug information for registers, so that the user can view them in the debugger. You could use standard C to define them manually:

#define PTDDD (*(volatile unsigned char*)0x0007)

But that will take quite some work if you intend to define all registers in the register map.

Personally, I hate the non-standard syntax, so I use a little program I've written myself, to parse the pdf manual and generate a register map with the same syntax as above, based on the names in the manual.


However... why would you ever want to compile a MCU register map in Windows? It does not make any sense. Visual Studio knows null and void about Freescale microcontrollers and therefore cannot generate any binaries for them.

0
s0nic2k On

Tons of things in CodeWarrior do not follow the C standard. Lundin is 100% correct in saying this is done so that the debugger can view registers in HIWAVE.

The bit register definitions are also nonstandard and caused me problems in some cases when porting code to other processors. Many other toolchains follow strict ANSI C rules.

The only reason I can think of, why this is being pulled into Visual Studio is because the person asking the question is either developing a tool for that processor or perhaps a simulator or even, a complete IDE/development tool. Not entirely unlikely considering how bad Codewarrior is now.

Complaining to Freescale is futile. I have gone all the way to the joint GM for my region, even complained on their forums, they do not listen.