Thread: what is difference between global extern variable and local extern variable ?

  1. #1
    Registered User
    Join Date
    Nov 2019
    Posts
    66

    what is difference between global extern variable and local extern variable ?

    I am not clear about the life time and scope of global extern variable and local extern variable

    extern may be local or global. What is difference between local extern and global extern variable? . I think the difference is only with the life time not in scope


  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,926
    The difference is purely in the scope of the declaration. Either way, it declares a variable as having external linkage (although if there is a prior declaration of that variable visible that has internal linkage, this declaration will refer to that variable instead).
    Last edited by laserlight; 04-13-2020 at 09:51 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 05-07-2017, 12:29 PM
  2. Replies: 7
    Last Post: 04-10-2017, 01:58 AM
  3. static global variable and static extern global variable
    By gunjansethi in forum C Programming
    Replies: 8
    Last Post: 01-12-2011, 01:00 AM
  4. using extern to have a global variable
    By steve1_rm in forum C Programming
    Replies: 3
    Last Post: 01-29-2009, 06:44 AM
  5. Static Local Variable vs. Global Variable
    By arpsmack in forum C Programming
    Replies: 7
    Last Post: 08-21-2008, 03:35 AM

Tags for this Thread