template 클래스의 va_list/va_end에 대해서...

purewell의 이미지

template<typename TYPE>
class MyClass
{
  public:
    void Print(const TYPE* szFmt, ...)
     {
      va_list vList;
      va_start(vList, szFmt);
      Print(szFmt, vList);
      va_end(vList);
    }
};

Print(const char* szFmt, va_list vList) {...}
Print(const wchar_t* szFmt, va_list vList) {...}

위와 같은 코드를 컴파일하면 다음와 같은 오류를 냅니다.

Quote:
#g++ MyClass.cpp
MyClass.h:xx: error: there are no arguments to `va_end' that depend on a template parameter, so a declaration of `va_end' must be available
MyClass.h:xx: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)

그래서 다음과 같은 옵션으로 컴파일하면 경고가 뜹니다.

Quote:
#g++ MyClass.cpp -fpermissive
MyClass.h:xx:warning: there are no arguments to `va_end' that depend on a template parameter, so a declaration of `va_end' must be available

무엇이 문제인가요?

* -fpermissive 옵션은 호환되지 않는 코드를 허락해주는 옵션인데,
왠지 모르게 찜찜한 것이....

purewell의 이미지

자답입니다.

#include <cstdarg>


using namespace std;

cstdarg를 포함해줬더니 안 그러네요.

_____________________________
언제나 맑고픈 샘이가...
http://purewell.biz