Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Global variable initialization

Global variable initialization

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Naveen
    wrote on last edited by
    #1

    Till the last day I belived that the global variables gets initialized automatically. But last day while debugging, I found out that the application start from the WinMainCRTStartup() function. And then stepping through that function, I came accross a function like this. /* * do C++ constructors (initializers) specific to this EXE */ _initterm( __xc_a, __xc_z ); Then I understood that it is inside this function the global variables get initialized. That means the gloabl variable are explicity been initialized. Can any one tell me whats this __xc_a and __xc_z variables are? And how the _initterm is doing the initialization?

    nave

    M 1 Reply Last reply
    0
    • N Naveen

      Till the last day I belived that the global variables gets initialized automatically. But last day while debugging, I found out that the application start from the WinMainCRTStartup() function. And then stepping through that function, I came accross a function like this. /* * do C++ constructors (initializers) specific to this EXE */ _initterm( __xc_a, __xc_z ); Then I understood that it is inside this function the global variables get initialized. That means the gloabl variable are explicity been initialized. Can any one tell me whats this __xc_a and __xc_z variables are? And how the _initterm is doing the initialization?

      nave

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      It looks like __xc_a and __xc_z are arrays of function pointers - pointing to initialization functions. _initterm() loops through calling each function in __xc_a ... ? It's in the runtime source code - see crt0dat.c for _initterm() cinitexe.c for __xc_a and __xc_z crtexe.c for the xxxCRTStartup functions Mark

      N 1 Reply Last reply
      0
      • M Mark Salsbery

        It looks like __xc_a and __xc_z are arrays of function pointers - pointing to initialization functions. _initterm() loops through calling each function in __xc_a ... ? It's in the runtime source code - see crt0dat.c for _initterm() cinitexe.c for __xc_a and __xc_z crtexe.c for the xxxCRTStartup functions Mark

        N Offline
        N Offline
        Naveen
        wrote on last edited by
        #3

        Thanks mark. I found out more informations on http://msdn.microsoft.com/msdnmag/issues/01/01/hood/[^]

        nave

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups