Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to define the enum on global use in C?

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Hi,

Anyone know how to define the enum on global use? Example:
Code:
typedef enum{APPLE, BALL, CAT}thing;
thing things;

I try to put the whole code inside the .H file but the code can't done it...
How to use enum in multiple .C file? Please give example code.

Thank You.

Ya. I already got the answer. Add the extern in front of thing then put this line thing things; which you like to use at .C.

Code:
typedef enum{APPLE, BALL, CAT}thing;
extern thing things;


Good Luck. :D
 

Re: enum in C

in a.h

typedef enum{APPLE, BALL, CAT}thing;

in b.c
//make sure that path is correct for a.h. if it is loacl then u can do as below other
//wise u need to give the full path from the root

#include "a.h"

thing things;

int main()
{
return 0;


}
 

enum in C

sathishkrishna's approach would be better I think.
Ussually you don't want to declare global variables in a
".h" file.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top