2011/10/07

함수 이름 가져오는 매크로

흥배님의 블로그를 통해 함수 이름을 가져오는 매크로인 __FUNCTION__, __FUNCSIG__ 에 대해 알게되어 이와 유사한 매크로가 더 있는 찾아 보았다.



MSDN 에서 Predefined Macros 로 찾으니 쉽게 찾아 졌다.

흥배님께서 언급한 두 개의 매크로 외에 __FUNCDNAME__ 라는 녀석도 있었다. 이들의 쓰인 결과를 보면 어떤 역할을 하는 매크로 인지 쉽게 알 수 있다.



아래 코드는 MSDN에서 발췌한 코드 이다. MSDN의 Predefined Macros 페이지에 보다 다양한 매크로에 대해 설명 하고 있다.

// Demonstrates functionality of __FUNCTION__, __FUNCDNAME__, and __FUNCSIG__ macros
void exampleFunction()
{
printf("Function name: %s\n", __FUNCTION__);
printf("Decorated function name: %s\n", __FUNCDNAME__);
printf("Function signature: %s\n", __FUNCSIG__);

// Sample Output
// -------------------------------------------------
// Function name: exampleFunction
// Decorated function name: ?exampleFunction@@YAXXZ
// Function signature: void __cdecl exampleFunction(void)
}

 



Predefined Macros on MSD

Original Post :
http://neodreamer-dev.tistory.com/584

No comments :

Post a Comment