Reputation: 304
Does gcc add atribute in signature of function, or not? Will these functions be compiled if it's in the same source file?
void*__attribute__ ((noinline)) GetCurrentIp(void) {
some code...
}
void*GetCurrentIp(void);
void*__attribute__ ((always_inline)) GetCurrentIp(void)
Upvotes: 0
Views: 272
Reputation: 19395
Even if the question is about C, we can let g++ answer it (see Function Names as Strings).
f.C
:
#include <stdio.h>
extern "C"
void *__attribute__((noinline)) GetCurrentIp(void)
{
printf("signature of %s: %s\n", __func__, __PRETTY_FUNCTION__);
return __builtin_return_address(0);
}
int main()
{
GetCurrentIp();
return 0;
}
> g++ f.C
> a.out
signature of GetCurrentIp: void* GetCurrentIp()
So, the attribute is not part of the signature.
Upvotes: 2
Reputation: 8871
No, it does not. Attributes are not added to function signature, so you'll receive error: redefinition of 'GetCurrentIp'
The main reason is that function signatures are a characteristic of the language (C
in this case), and not of the implementation (in this case gcc
) that help you to match them in the expressions, so there must be no implementation dependency there. And attributes (like the one you mention, a hint for the compiler to never expand that function inline) are directives to the compiler to generate the code as you want. Indeed, attributes as defined by gcc
are not a characteristic of the language, and as such program meaning should not change by the inclusion or exclusion of these.
Upvotes: 1