Tuesday, December 20, 2011

Call function before MAIN

#include

#ifndef __GNUC__

void beforemain();
void aftermain();
#pragma startup beforemain
#pragma exit aftermain

#else

void beforemain() __attribute__((constructor));
void aftermain()__attribute__((destructor));

#endif

int main()
{
printf("\nim inside main\n");
return 0;
}

void beforemain()
{
printf("\nim before the main and is executing.........!!!\n");
}

void aftermain()
{
printf("\nim after termination of main and is executing.........!!!\n");
}

No comments:

Post a Comment