>Bouquet of questions-3

>o How can you add attributes in gcc, e.g., changing function call way from cdecl to stdcall?

GCC allows you to attribute your functions with __attribute__ macro.
This macro allows you to write more readable, clean code. I liked,

– __attribute__((destructor))
– __attribute__((constructor))
– __attribute__((warning(“Function definition is not found)))

There are plenty of them, check them out at: http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

o What does following code do?

int flag = 2;
int (*fp)(void) __attribute__((cdecl));
void fun() __attribute__((warning(“No definition”)));
int main(void)
{
//fun();
fp = main;
puts(“called”);
while(flag–) {
int x = (*fp)();
}
}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s