Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

C-Typedef struct with µClinux

Hi all,

I'm trying to use in my header file the simple following code :

typedef enum

{

COUNTER1 = 0,

COUNTER2 = 1,

} ERRORCOUNTER;

and in my .c main file something like :

U32 GetErrorCount(errorcounter Counter,FE_STV0900_DEMOD_t Demod)

{

...

/*Read the Error value*/

switch(Counter)

{

case COUNTER1:

...

}

but when I compile, I always get the same compilation error :

"error: `ERRORCOUNTER' undeclared (first use in this function)"

whereas I checked the# include header declarations twice !!

So here is my question : can we use typedef enum and typedef struct in µClinux ??

Thanks for your help !

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The simple answer is of course you can typedef structs and enums. Your example is not complete enough to see what's wrong. The obvious question is: did you include the header?

    good luck, Alex
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    <div class='quotetop'>QUOTE (papyenfurie @ Jul 16 2009, 01:55 PM) <{post_snapback}> (index.php?act=findpost&pid=23153)</div>

    --- Quote Start ---

    So here is my question : can we use typedef enum and typedef struct in µClinux ??[/b]

    --- Quote End ---

    For that matter, the question should be whether our compiler (nios2-linux-uclibc-gcc) supports that kind of strucutre. I&#39;m pretty sure it does, I use it all the time.

    Could you please post the smallest, simplest source code that reproduces the same error you are seeing? It would make things easier for people wanting to help.

    Cheers,

    Ricardo.