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

von cprog (Guest)

Rate this post
0 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
} 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
0 useful
not useful
The second typedef defines a function type like this:
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
0 useful
not useful
Ok great, thank you.  That clears things up.

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


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.