찾는 방법에 gcc가 차이가 나는이는 선언
// util.h
//
// ... lots of stuff ...
std::istream& operator>>(std::istream& is, const char *str);
std::istream& operator>>(std::istream& is, char *str);
그리고
// util.cpp
//
// lots of stuff again
//! a global operator to scan (parse) strings from a stream
std::istream& operator>>(std::istream& is, const char *str){
parse(is, str); return is;
}
//! the same global operator for non-const string
std::istream& operator>>(std::istream& is, char *str){
parse(is, (const char*)str); return is;
}
과 같은 istreams에 대한 util.h 연산자의 오버로드/cpp를 >> (. V 4.6.3)
std::istream file;
char *x, *y;
// opening and allocating space for strings comes here
file >> "[ " >> x >> "," >> y >> " ]";
이것은 GCC/g와 완벽하게 잘 ++ 작동하지만 지금은 C를 사용하고 싶었 : 다른 파일에 I는 다음과 같이 구성이 사용 랭 (V 3.0) 및 해당 연산자 오버로딩을 찾을 수 없다는 진술 오류를 가지고 : GCC는 아무런 문제가없는 반면, 적절한 선언을 찾을 수없는 그 소리 왜
clang -ferror-limit=1 -g -Wall -fPIC -o ors.o -c ors.cpp
ors.cpp:189:21: error: invalid operands to binary expression ('std::istream' (aka 'basic_istream<char>') and 'const char [2]')
file >> "[ " >> x >> "," >> y >> " ]";
~~~~^~~~~
/usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../include/c++/4.6.3/istream:121:7: note: candidate function
not viable: no known conversion from 'const char [2]' to '__istream_type &(*)(__istream_type &)' for 1st argument;
operator>>(__istream_type& (*__pf)(__istream_type&))
[[ lots of other possible candidates from the stl ]]
. 이 문제를 어떻게 해결할 수 있습니까?
각 파일에'# include'd를 어떻게 보여줄 수 있습니까? 아마도 g ++ 구현은 clang이 아닌 다른 헤더를 포함하고있을 것입니다. –
컴파일러와 다른 동작에 대해 질문 할 때 항상 작은 컴파일 가능한 코드 샘플을 게시하는 것이 좋습니다. –
나는 최소한의 컴파일 가능한 예제를 얻으려고 노력할 것이다. – hildensia