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 6198823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:04:51+00:00 2026-05-24T04:04:51+00:00

Must program execution start from main, or can the starting address be modified? #include

  • 0

Must program execution start from main, or can the starting address be modified?

#include <stdio.h>

void fun();

#pragma startup fun

int main()
{
    printf("in main");
    return 0;
}

void fun()
{
    printf("in fun");
}

This program prints in fun before in main.

  • 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-05-24T04:04:52+00:00Added an answer on May 24, 2026 at 4:04 am

    The ‘#pragma’ command is specified in the ANSI standard to have an arbitrary implementation-defined effect. In the GNU C preprocessor, ‘#pragma’ first attempts to run the game ‘rogue’; if that fails, it tries to run the game ‘hack’; if that fails, it tries to run GNU Emacs displaying the Tower of Hanoi; if that fails, it reports a fatal error. In any case, preprocessing does not continue.

    — Richard M. Stallman, The GNU C Preprocessor, version 1.34

    Program execution starts at the startup code, or “runtime”. This is usually some assembler routine called _start or somesuch, located (on Unix machines) in a file crt0.o that comes with the compiler package. It does the setup required to run a C executable (like, setting up stdin, stdout and stderr, the vectors used by atexit()… for C++ it also includes initializing of global objects, i.e. running their constructors). Only then does control jump to main().

    As the quote at the beginning of my answer expresses so eloquently, what #pragma does is completely up to your compiler. Check its documentation. (I’d guess your pragma startup – which should be prepended with a # by the way – tells the runtime to call fun() first…)

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

Sidebar

Related Questions

I have program, that must interact with a console program before my program can
When starting the external program (let's call it EX for brevity) from within Matlab
I have lots(+2000) of GUIDs(in some network class) and my program must find one
I'm using NSMapTable in a program that must run under both 3.0 and 2.2.1.
I have a program that still must target Windows XP (_WIN32_WINNT 0x501), as most
I must be overlooking something terribly obvious. I need to execute a C program,
I have the need to express simple conditionals as program input. The input must
I'm having some trouble implementing DoubleBuffer into my program. Before you faint from the
In a script you must include a #! on the first line followed by
I need some way to do the following efficiently in C#: Make program execution

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.