__attribute__ ((weak)) 의 의미?

air74의 이미지

안녕하세요.

갈수록 허접한 질문만 쓰게 되네요.

void * __attribute__ ((weak)) 불라불라(함수이름) 에서 앞에 붙는

__attribute__ ((weak)) 의 의미는 모에요?

그럼 수고 하세요.

송지석의 이미지

googling :-)

http://kolpackov.net/pipermail/notes/2004-March/000006.html

Good day,

While playing with glibc I noticed one interesting technique. It is
based on gcc's extension that allows you to declare weak symbols. In
essence it works like this:

extern void weak_f (void) __attribute__ ((weak));

int main ()
{
if (weak_f)
{
weak_f ();
}
}

When you link such code ld won't complain if weak_f is unresolved.
Plus you can check at run-time if symbol has been resolved as shown
above.