EmbDev.net

Forum: ARM programming with GCC/GNU tools confused by "typedef enum"


von cprog (Guest)


Rate this post
useful
not useful
I'm integrating a C library into my C project and have run across 
compile issues that have left me thoroughly confused.

First we have this in a header file (keep in mind I've changed the 
variable names):

typedef enum
{
    ITEM1,
    ITEM2,
    ITEM3,
    ITEM4,
    ITEM5
} MyError;

Then in a source file:

typedef MyError( *send_pdu ) ( unsigned int8  adr,
const unsigned int8 * pdu, unsigned int16 len );


I'm really confused as to the "typedef enum".  I know what typedef does, 
and I know what enum does.  What is the second statement doing?

von gjlayde (Guest)


Rate this post
useful
not useful
The second typedef defines a function type like this:
1
MyError func (unsigned int8, const unsigned int8*, unsigned int16);

Your typed are odd.

You really really should switch to C99's stdint.h and use uint8_t et al.

von cprog (Guest)


Rate this post
useful
not useful
Ok great, thank you.  That clears things up.

This is an 8-bit PIC compiler so I would expect some weirdness.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.