[OpenIndiana-discuss] weird C++ problem

Rennie Allen rennieallen at gmail.com
Mon Apr 1 18:37:24 UTC 2013


Have you tried including <cstring> rather than string.h ?



On 4/1/13 11:29 AM, "Apostolos Syropoulos" <asyropoulos at yahoo.com> wrote:

>Hello everybody,
>
>I was trying to compile a program and one file failed to compile
>with g++ 4.7.2 but it compiles with CC: Sun C++ 5.12 SunOS_i386
>2011/11/16.
>
>The following little program reproduces the error I got initially:
>
>#include <iostream>
>#include <string>
>using namespace std;
>    namespace KPS {
>        extern "C" {
>            #include <string.h> //it includes another header that
>eventually
>        }                       // included this header.
>    }
>    using namespace KPS;
>
>int main() {
>  std::string x;
>  string y = "abcdef";
>  cout << y << endl;
>}
>
>The error I am getting follows:
>
>yy.cpp: In function ‘int main()’:
>yy.cpp:12:3: error: reference to ‘std’ is ambiguous
><built-in>:0:0: error: candidates are: namespace std { }
>In file included from /usr/include/string.h:33:0,
>                 from yy.cpp:6:
>/usr/include/iso/string_iso.h:55:15: ??????:                 namespace
>KPS::std { }
>yy.cpp:12:3: ??????: reference to ‘std’ is ambiguous
><built-in>:0:0: ??????: candidates are: namespace std { }
>In file included from /usr/include/string.h:33:0,
>                 from yy.cpp:6:
>/usr/include/iso/string_iso.h:55:15: ??????:                 namespace
>KPS::std { }
>yy.cpp:12:15: ??????: expected ‘;’ before ‘x’
>
>According to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1773
>gcc 4.7.2 defines __cplusplus to be equal to 199711L. And of
>course CC assumes that the value of __cplusplus is
>199711L. The line in iso/string_iso.h that makes
>g++ to complain is line 55 of this file:
>
>line 54: #if __cplusplus >= 199711L
>line 55: namespace std {
>line 56: #endif
>
>Has anyone seen this thing before?
>
>A.S.
>
>----------------------
>Apostolos Syropoulos
>Xanthi, Greece
>_______________________________________________
>OpenIndiana-discuss mailing list
>OpenIndiana-discuss at openindiana.org
>http://openindiana.org/mailman/listinfo/openindiana-discuss





More information about the OpenIndiana-discuss mailing list