Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7813775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:58:51+00:00 2026-06-02T04:58:51+00:00

I am trying to ensure a function will get called first by the program

  • 0

I am trying to ensure a function will get called first by the program to ensure the initizilation of critical objects. However, I am confused as to how init_seg is suppose to be getting used/called.

For example, from the documentation at msdn it would seem as if the following would be the first to be called.

#pragma init_seg( ".CRT$XCC" )

static void InitializeStuff()
{
    printf("InitializeStuff\n");
}

However, that does not seem to be the case as that function will just plainly not get called automatically (unless I call it explicitly, of course).

How can I use init_set to ensure a function is called before the rest of my other executing code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:58:52+00:00Added an answer on June 2, 2026 at 4:58 am

    If i have understood it right you place all global variables that you want to be initialized first in the same file as the #pragma init_seg

    Example:

    #pragma init_seg( ".CRT$XCB" )
    
    class A
    {
        A()
        {
            printf("first!\n");
        }
    };
    
    static A first;
    

    And make sure you dont place any other globals in that file than the ones you want to initialized first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do something seemingly simple: ensure that Application_BeginRequest is called for every
I'm trying to find the correct event to listen for that will ensure that
I am trying to use a closure to ensure that a function can only
I am trying to write a CGFunctionRef that will act as a shading function
I'm trying to create a datagrid which will resize vertically to ensure all the
I'm trying to ensure that a variable value is non-nil before proceeding - the
I am trying to figure out the most efficient way to ensure cross-browser compatibility.
I'm trying to move a file but I want to ensure that it exists
I was trying to write a validation for Rails to ensure that a price
I am trying to rename files with a dash in the name to ensure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.