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

For the following program: int DivZero(int, int, int); int main() { try { cout
I'm building my first Android program from a book. It kept crashing on an
I've got a function in Jython, this function uses Popen to run another program
Followup question from this one: Swing font names do not match? (Making a font
I want to program a daemon-manager that takes care that all daemons are running,
I researched this around and still can't seem to solve this problem. I have
i edited my code to the following: using System; using System.Collections.Generic; using System.Linq; using
I have a very simple command line Java application that I wish to port
What happens when I use an ObjectInputStream to read in a serialized object that
I have a game application that I will be running in a web browser

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.