This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Enum isn't recognized in prototype

Hi, I'm about to pull my hair out.

I have a enumerated type in a file called iap_tools.h that looks like this:

enum ChipType
{
  master_chip,
  slave_chip,
  comm_chip
};

I have a function declared in master.c that looks like this:

void start_firmware_copy( enum ChipType chip_type ){}

I have its prototype in a file called master.h, and it looks like this:

void start_firmware_copy( enum ChipType chip_type );

In master.h and master.c, I've #include "iap_tools.h", so everyone should know about the enumerated ChipType. But when I compile, I get this error:

*** ERROR C230 IN LINE 173 OF MASTER.H: 'ChipType': unknown struct/union/enum tag

So just for fun, I copy the ChipType definition into master.h, but it complains that master_chip (etc) was redefined and that ChipType was a duplicate struct/union/enum tag! It knows darn well what ChipType is! Why is it giving me an error? I use other enumerated types exactly (as far as I can tell) the way I've used ChipType, and they work just fine.

If I change the enumerated type to an unsigned char, everything compiles fine.

So does anyone have a clue what's going on here?

Thanks,
-JB

Parents
  • "And come on; does anyone really need to be told that you have to #include the definitions above their use?"

    Unfortunately, there are plenty of examples of posters here who really do need to be told such basic things as that...

    :-(

    "Have you ever heard of someone overwriting compiler namespace when using the _H_ notation? This seems to be a super-common practice."

    The fact that it's common doesn't make it right;
    The fact that a lot of people get away with it doesn't make it right.

Reply
  • "And come on; does anyone really need to be told that you have to #include the definitions above their use?"

    Unfortunately, there are plenty of examples of posters here who really do need to be told such basic things as that...

    :-(

    "Have you ever heard of someone overwriting compiler namespace when using the _H_ notation? This seems to be a super-common practice."

    The fact that it's common doesn't make it right;
    The fact that a lot of people get away with it doesn't make it right.

Children
No data