HP 장비에서 aCC 로 컴파일을 하던도중 아래의 에러가 발생했다.
“/opt/aCC/include_std/utility”, line 99: error #2070: incomplete type is not
allowed
first_type first;
^
detected during:
instantiation of class “std::pair<_TypeT, _TypeU> [with
_TypeT=const std::string, _TypeU=char *]” at line 97 of
“/opt/aCC/include_std/rw/tree”
instantiation of class “__rw::__rw_rb_tree_node<_Alloc, _Val,
_Key, _KeyOf> [with
_Alloc=std::allocator<std::pair<const std::string, char
*>>, _Val=std::pair<const std::string, char *>,
_Key=std::string,
_KeyOf=__rw::__select1st<std::pair<const std::string,
char *>, std::string>]” at line 282 of
“/opt/aCC/include_std/rw/tree”
instantiation of class “__rw::__rb_tree<_Key, _Val, _KeyOf, _Comp,
_Alloc> [with _Key=std::string, _Val=std::pair<const
std::string, char *>,
_KeyOf=__rw::__select1st<std::pair<const std::string,
char *>, std::string>, _Comp=std::less<std::string>,
_Alloc=std::allocator<std::pair<const std::string, char
*>>]” at line 102 of “/opt/aCC/include_std/map”
instantiation of class “std::map<_Key, _TypeT, _Compare,
_Allocator> [with _Key=std::string, _TypeT=char *,
_Compare=std::less<std::string>,
_Allocator=std::allocator<std::pair<const std::string,
char *>>]” at line 54 of “LocalRepository.h”
이유인즉, HP 컴파일러 aCC 가 버전 6로 넘어오면서 기존(aCC version 5)에서 허용했던 C++ 타입에 대한 처리를 더이상 허용하지 않으면서 발생한 문제였다.
관련링크 : http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=2708d7c682f02110d7c682f02110275d6e10RCRD#_iso-39._acc6_detects_instantiation_
공식 문서내용은 다음과 같다.
ISO-39. aCC6 detects instantiation conflicts earlier (2403)
|
|
 |
Points of instantiation differ for member functions, so reporting of instantiation conflicts can differ. This is simply a behavior difference, and not a compatibility issue. However, the following code snippet illustrates an incompatibility in the use of repeated const keywords, which aCC5 allows and aCC6 does not. To fix this code, don’t instantiate the template with a const int; simply use int:
template <class T>
struct S {
void foo(T *i) {}
void foo(const T *i) {}
};
int main() {
int i = 5;
#ifdef WORKS_IN_BOTH
S<int> s;
#else
S<const int> s;
#endif
return 0;
}
내용인즉, C++ 에서 template 사용시 const 를 사용하지 말라는 뜻이다.
위의 에러에서 문제가 해당 라인(line 54 of “LocalRepository.h”)을 찾아가보니 아래와 같이 선언되있었다.
map<string, char*> m_mapStringMainData;
뭔가 이상했다. map 선언 중, 어디에도 const 는 있지 않았다. 어찌된 일일까.
한참을 헤매고 주위에 도움을 구해서 찾아낸 정답은 정말 엉뚱한 곳에 있었다.
바로 iostream 였다.
다음의 라인을 추가하여 깔끔히 문제를 해결할 수 있었다.
#include <iostream>
왜 이런 문제가 생긴 것일까? 조금 더 질문을 해본 결과 한가지 재미있는 사실을 알 수 있었다.
이전 버전의 aCC 에서는 iostream 을 include 하면 또 안된다는 것..
아직 배워야할 것이 많다..