1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

how to change the entry point in gcc

Discussion in 'C' started by asitmahato, Sep 21, 2011.

  1. asitmahato

    asitmahato New Member

    Joined:
    Sep 5, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    How to change the entry point of gcc compiler ?

    I mean the code will look like the bellow one.
    Code:
    #include<stdio.h>
    int entry()  //this is the new entry point instead of main.
    {
    return 0;
    }
    thank you very much..
     
  2. poornaMoksha

    poornaMoksha New Member

    Joined:
    Jan 29, 2011
    Messages:
    150
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Software developer
    Location:
    India
    try -e option of gcc..may be this could help
     
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Not a good idea unless you deliberately want to obfuscate your code. Instead try this:
    Code:
    int main()
    {
      return entry();
    }
    
    then continue as previously, coding from entry().
     
  4. poornaMoksha

    poornaMoksha New Member

    Joined:
    Jan 29, 2011
    Messages:
    150
    Likes Received:
    33
    Trophy Points:
    0
    Occupation:
    Software developer
    Location:
    India
    Yup not a good idea but the question was to change the entry point so that we do not have to keep main() in it. Is there a more elegant way other than using -e option??
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Changing the entry point of a C program to anything other than main() fails ALL "elegance" tests. The best you can achieve is an ugly hack.

    What's wrong with the -e option? Why doesn't it do what you want?
     

Share This Page