Re: enum variables and extern
- From: Harald van Dijk <truedfx@xxxxxxxxx>
- Date: 30 Apr 2007 07:59:43 -0700
Charlie wrote:
I have a file, data.c, where I define all of my global variables.
I then have a header file, data.h, which I include in every file in
which I reference all of the variables defined in data.c.
For the most part, I am having no problem with this. However, I
defined an variable of type myenum in data.c:
enum myenum
{
Mon,
Tues,
Wed
} enum_var;
Now when I try to reference enum_var in data.h, the compiler gives me
issues. I have tried multiple ways of referencing it and defining it,
but nothing is working. I guess I just don't understand something
about enum types and/or extern.
You need to define 'enum myenum' everywhere you reference it. You
can't use an enum by merely declaring it, as you can for variables. So
it has to be in the data.h file.
data.c:
#include "data.h"
enum myenum enum_var;
data.h:
extern enum myenum
{ ... } enum_var;
or
data.h:
enum myenum
{ ... };
extern enum myenum enum_var;
.
- Follow-Ups:
- Re: enum variables and extern
- From: Charlie
- Re: enum variables and extern
- References:
- enum variables and extern
- From: Charlie
- enum variables and extern
- Prev by Date: Re: String Comparision
- Next by Date: Re: String Comparision
- Previous by thread: enum variables and extern
- Next by thread: Re: enum variables and extern
- Index(es):
Relevant Pages
|