[cc65] Struct embedded enum

Date view Thread view Subject view

From: Keates, Mark (Mark.Keates_at_dendrite.com)
Date: 2003-10-09 12:43:24


Hi,

This is a bit ugly, the struct below contained an enum:

struct threadQueue {
    ...
    enum {
	THREAD_JUST_BORN = 0,	/* Not "start"ed yet */
	THREAD_ACTIVE = 1,	/* Currently running, or on Run queue */
	THREAD_SUSPENDED = 2,   /* Waiting for monitor or alarm */
	THREAD_DEAD = 3		/* Thread has quit */
    } state;
};

CC65 couldn't evaluate the rhs of this statement and so I used a 
set of #defines to get around it.

        if (CurrentThread->state == THREAD_ACTIVE) {

The question is, is there a specific way that the enum label could be
referenced?
I guess a better way would be to typedef the enum outside of the struct and
then
use then declare 'state' properly within the struct?

Thanks for the other responses + bug fix, I had the same problem with a
function
returning a union but luckily it was only 4 bytes long and so I was able to
get by
passing/returning the 'i' element ;)

typedef union {
    struct {
	unsigned short nameKey;
	unsigned short typeKey;	/* either MethodTypeKey or FieldTypeKey */
    } nt;
    unsigned long i;
} NameTypeKey;

Mark



**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-10-09 12:46:20 CEST