Jul 10, 2006 #1 H 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.
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.
Jul 19, 2006 #2 S sathishkrishna Newbie level 6 Joined Sep 10, 2004 Messages 12 Helped 2 Reputation 4 Reaction score 0 Trophy points 1,281 Activity points 339 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; }
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; }
Jul 19, 2006 #3 A Anno Advanced Member level 4 Joined Feb 8, 2006 Messages 106 Helped 14 Reputation 28 Reaction score 0 Trophy points 1,296 Location South Africa Activity points 1,899 enum in C sathishkrishna's approach would be better I think. Ussually you don't want to declare global variables in a ".h" file.
enum in C sathishkrishna's approach would be better I think. Ussually you don't want to declare global variables in a ".h" file.