Thread: On globals of different modules.

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    106

    On globals of different modules.

    Hello, this is the question:
    when you compile different modules (.obj) and then you link them all to get the executable, how are the globals of each module allocated? Are them global variables or are them static (private) of each module, or anything else?
    Thanks a lot for answer.

  2. #2
    Compulsive Liar Robc's Avatar
    Join Date
    Jul 2004
    Posts
    149
    >Are them global variables or are them static (private) of each module, or anything else?
    It depends on how they're declared. Global variables as they're commonly called have static storage duration, but they can have either external or internal linkage depending on whether the declaration is qualified with static or extern or nothing. If a variable has internal linkage, it's only visible within the file in which it was declared. If it has external linkage then it's visible to other files.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. Sugguestion on choosing my modules
    By ssharish2005 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-27-2007, 05:44 PM
  3. Multiple Modules
    By rwmarsh in forum C++ Programming
    Replies: 6
    Last Post: 02-18-2006, 04:34 PM
  4. Problems with modules
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 8
    Last Post: 07-29-2005, 08:56 PM
  5. globals & multiple .c files
    By Unregistered in forum C Programming
    Replies: 8
    Last Post: 10-30-2002, 09:43 PM