Thread: how to declare an external variable of type "enum"?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    78

    Unhappy how to declare an external variable of type "enum"?

    If I have a global integer x, which I declare in main.c and want to use in function.c, I am able to do so by stating the following in header.h:

    Code:
    extern int x;
    However, what do I do if I have a global enum? In my main.c I declare a global variable as follows:

    Code:
    enum whoseturn {B, W};
    enum whoseturn color=W;
    But how do I declare it in my header in order to use it in function.c? I have tried such things as

    Code:
    extern enum whoseturn color;
    extern whoseturn color;
    extern enum color;
    But I consistently get error messages when I try to set color to B or W, to the effect B and W have not been declared. How do I do this globally?
    Last edited by Adam Rinkleff; 06-22-2011 at 07:35 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GCC lets you forward declare a struct with "class /name/"
    By Mozza314 in forum C++ Programming
    Replies: 12
    Last Post: 02-20-2011, 04:52 AM
  2. Replies: 3
    Last Post: 05-01-2010, 02:26 AM
  3. problem about handle "double" variable type? or?
    By Mathsniper in forum C Programming
    Replies: 4
    Last Post: 12-31-2006, 10:11 PM
  4. "Deciding" in runtime the type of a variable
    By mikahell in forum C++ Programming
    Replies: 28
    Last Post: 07-22-2006, 09:51 AM
  5. Ask about error when declare "static inline int"
    By ooosawaddee3 in forum C Programming
    Replies: 3
    Last Post: 05-25-2002, 05:03 AM