>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)();
}
}