in code bellow you declare main because any executable needs an entrypoint you cannot fake that anyway, it doesn't use main at all to invoke those functions.
http://www.geeksforgeeks.org/archives/14538 #include<stdio.h> /* Apply the constructor attribute to myStartupFun() so that it is executed before main() */ void myStartupFun (void) __attribute__ ((constructor)); /* Apply the destructor attribute to myCleanupFun() so that it is executed after main() */ void myCleanupFun (void) __attribute__ ((destructor)); /* implementation of myStartupFun */ void myStartupFun (void) { printf ("startup code before main()\n"); } /* implementation of myCleanupFun */ void myCleanupFun (void) { printf ("cleanup code after main()\n"); } int main (void) { printf ("hello\n"); return 0; } On Mon, Sep 19, 2011 at 1:51 PM, cegprakash <cegprak...@gmail.com> wrote: > is it possible to print something without a main function?? > I wonder how the code won't get any compile error > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Hatta -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.