Skip to content

extern, variable define else where

Sometimes we might need to declare global variable. Let say I have 5 files (cat.c, dog.c, tiger.c, rabbit.c and animal.c). I declare a global integer variable “debug” at animal.c

int debug;

In order to let other modules from other file besides animal.c to gain the global access, I need to add a line for ( cat.c, dog.c, tiger.c and rabbit.c).

extern int debug;

I use debug global variable to store the value of debug mode. With different debug mode, I can control what to print on screen to ease the debugging.

Categories: Uncategorized.

Comment Feed

One Response

  1. give me some examples on extern variables

    Ravi kiranJune 29, 2009 @ 4:37 pm



Some HTML is OK

or, reply to this post via trackback.