|
|
View previous topic :: View next topic |
Author |
Message |
Davng
Joined: 11 Sep 2003 Posts: 2
|
Void() in a structure |
Posted: Fri Sep 10, 2004 8:48 am |
|
|
Why I can't use this piece of code?
Code: |
typedef const struct _rom_desc_tsk
{
unsigned char prioinit;
unsigned int stackAddr;
void *nParameters; // Unknown type!
unsigned char futur_use;
unsigned char id_tch;
unsigned int ctx_tch;
} rom_desc_tsk;
|
The compiler don't let me use a void pointer inside the structure! The error that show me is: "unknown type"
thnx in advance
davng |
|
|
Ttelmah Guest
|
Re: Void() in a structure |
Posted: Fri Sep 10, 2004 10:21 am |
|
|
Davng wrote: | Why I can't use this piece of code?
Code: |
typedef const struct _rom_desc_tsk
{
unsigned char prioinit;
unsigned int stackAddr;
void *nParameters; // Unknown type!
unsigned char futur_use;
unsigned char id_tch;
unsigned int ctx_tch;
} rom_desc_tsk;
|
The compiler don't let me use a void pointer inside the structure! The error that show me is: "unknown type"
thnx in advance
davng |
I'm not suprised.
'void' has two different meanings. The first is effectively a 'null' defintion for data types (as in a function that returns nothing). The second form, _was an extension to C, that is part of the ANSI definitions_, where it replaces 'char *', as the generic data pointer. CCS C, _is not ANSI C_. It retains the original K&R defintions, where char * is the generic pointer.
Some 'ANSI like' forms are allowed in places, but most are dubious, and should be used with care...
Basically you are trying to use an ANSI C structure, in a C that does not relibly support this.
Change it to char *, and cast it to the type that is actually required, when accessed.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|