error 'unnamed fields'

R

Roman Mashak

Hello, All!

I'm trying to compile some driver for MIPS target, and get errors. I assumed
these may be related to C language.

tigon3.h:2225: unnamed fields of type other than struct or union are not
allowed
tigon3.h:2225: warning: no semicolon at end of struct or union
tigon3.h:2225: syntax error before numeric constant

and so on...

Here is abstract from tigon3.h where compiler complains:

typedef unsigned int LM_UINT32, *PLM_UINT32;
....
typedef volatile LM_UINT32 T3_32BIT_REGISTER, *PT3_32BIT_REGISTER;
....

typedef union T3_CPU
{
struct
{
T3_32BIT_REGISTER mode;
#define CPU_MODE_HALT BIT_10
#define CPU_MODE_RESET BIT_0
T3_32BIT_REGISTER state;
T3_32BIT_REGISTER EventMask;
T3_32BIT_REGISTER reserved1[4];
T3_32BIT_REGISTER PC; /* here error comes */
T3_32BIT_REGISTER Instruction;
T3_32BIT_REGISTER SpadUnderflow;
T3_32BIT_REGISTER WatchdogClear;
T3_32BIT_REGISTER WatchdogVector;
T3_32BIT_REGISTER WatchdogSavedPC;
T3_32BIT_REGISTER HardwareBp;
T3_32BIT_REGISTER reserved2[3];
T3_32BIT_REGISTER WatchdogSavedState;
T3_32BIT_REGISTER LastBrchAddr;
T3_32BIT_REGISTER SpadUnderflowSet;
T3_32BIT_REGISTER reserved3[(0x200-0x50)/4];
T3_32BIT_REGISTER Regs[32];
T3_32BIT_REGISTER reserved4[(0x400-0x280)/4];
}reg;
}T3_CPU, *PT3_CPU;

What may be the reason?

Thanks in advance for hints!

With best regards, Roman Mashak. E-mail: (e-mail address removed)
 
I

Ian Collins

Roman said:
Hello, All!

I'm trying to compile some driver for MIPS target, and get errors. I assumed
these may be related to C language.

tigon3.h:2225: unnamed fields of type other than struct or union are not
allowed
tigon3.h:2225: warning: no semicolon at end of struct or union
tigon3.h:2225: syntax error before numeric constant
[snip]
T3_32BIT_REGISTER PC; /* here error comes */
[snip]

Have you tried a different name, looks like PC is a macro defined
somewhere else.
 
R

Roman Mashak

Hello, Ian!
You wrote on Tue, 30 May 2006 14:29:18 +1200:

??>> fields of type other than struct or union are not
??>> allowed tigon3.h:2225: warning: no semicolon at end of struct or union
??>> tigon3.h:2225: syntax error before numeric constant
??>>
IC> [snip]
??>> T3_32BIT_REGISTER PC; /* here error comes */
IC> [snip]

IC> Have you tried a different name, looks like PC is a macro defined
IC> somewhere else.
It's not defined anywhere in the code, I checked twice.

<OT> Moreover, it's compiled on host machine (x86), but failes only in
cross-compiling case. </OT>

With best regards, Roman Mashak. E-mail: (e-mail address removed)
 
I

Ian Collins

Roman said:
Hello, Ian!
You wrote on Tue, 30 May 2006 14:29:18 +1200:

??>> fields of type other than struct or union are not
??>> allowed tigon3.h:2225: warning: no semicolon at end of struct or union
??>> tigon3.h:2225: syntax error before numeric constant
??>>
IC> [snip]
??>> T3_32BIT_REGISTER PC; /* here error comes */
IC> [snip]

IC> Have you tried a different name, looks like PC is a macro defined
IC> somewhere else.
It's not defined anywhere in the code, I checked twice.

<OT> Moreover, it's compiled on host machine (x86), but failes only in
cross-compiling case. </OT>
Well there must be something wrong with it.

Have you tried

#if defined PC
# error "PC defined"
#endif
 
R

Roman Mashak

Hello, Ian!
You wrote on Tue, 30 May 2006 15:58:33 +1200:

IC>>> Have you tried a different name, looks like PC is a macro defined
IC>>> somewhere else.
??>> It's not defined anywhere in the code, I checked twice.
??>>
??>> <OT> Moreover, it's compiled on host machine (x86), but failes only in
??>> cross-compiling case. </OT>
IC> Well there must be something wrong with it.

IC> Have you tried

IC> #if defined PC
IC> # error "PC defined"
IC> #endif
You were right. I checked the driver source code, but it seems like 'PC' was
defined somewhere inside of cross-compiler toolchain. I renamed all
instances and it worked out. Thanks for hint.

With best regards, Roman Mashak. E-mail: (e-mail address removed)
 
B

Barry Schwarz

Hello, All!

I'm trying to compile some driver for MIPS target, and get errors. I assumed
these may be related to C language.

tigon3.h:2225: unnamed fields of type other than struct or union are not
allowed
tigon3.h:2225: warning: no semicolon at end of struct or union
tigon3.h:2225: syntax error before numeric constant

and so on...

Here is abstract from tigon3.h where compiler complains:

typedef unsigned int LM_UINT32, *PLM_UINT32;

Is "LM_UINT32" that much easier to type than "unsigned int"?
...
typedef volatile LM_UINT32 T3_32BIT_REGISTER, *PT3_32BIT_REGISTER;
...

typedef union T3_CPU

You are aware that your union consists of exactly one member? That
member is the untagged structure named reg. Normally a union consists
of multiple members that overlay each other. There are no overlaid
objects here.
{
struct
{
T3_32BIT_REGISTER mode;
#define CPU_MODE_HALT BIT_10
#define CPU_MODE_RESET BIT_0

These really don't belong inside your structure.
T3_32BIT_REGISTER state;
T3_32BIT_REGISTER EventMask;
T3_32BIT_REGISTER reserved1[4];
T3_32BIT_REGISTER PC; /* here error comes */

Already answered else thread.
T3_32BIT_REGISTER Instruction;
T3_32BIT_REGISTER SpadUnderflow;
T3_32BIT_REGISTER WatchdogClear;
T3_32BIT_REGISTER WatchdogVector;
T3_32BIT_REGISTER WatchdogSavedPC;
T3_32BIT_REGISTER HardwareBp;
T3_32BIT_REGISTER reserved2[3];
T3_32BIT_REGISTER WatchdogSavedState;
T3_32BIT_REGISTER LastBrchAddr;
T3_32BIT_REGISTER SpadUnderflowSet;
T3_32BIT_REGISTER reserved3[(0x200-0x50)/4];
T3_32BIT_REGISTER Regs[32];
T3_32BIT_REGISTER reserved4[(0x400-0x280)/4];
}reg;
}T3_CPU, *PT3_CPU;


Remove del for email
 
K

Keith Thompson

Barry Schwarz said:
[...]
Here is abstract from tigon3.h where compiler complains:

typedef unsigned int LM_UINT32, *PLM_UINT32;

Is "LM_UINT32" that much easier to type than "unsigned int"?

No, but it does mean something different. unsigned int can be any
size, from 16 bits up. LM_UINT32 is 32 bits (or else the name is
grossly misleading).

But a better way to do this is to use the standard uint32_t from
<stdint.h> (or uintleast32_t, or uintfast32_t, depending on your
actual requirements). If you don't have <stdint.h>, it's easy enough
to write your own (Google "doug gwyn q8").
 
I

Ian Collins

Barry said:
These really don't belong inside your structure.
But they don't do any harm here and putting them here shows they
'belong' to the mode register. This layout is quite common in embedded
register structure definitions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top