is not a member of global namespace

99263 ワード

今日demoを書いて、コンパイルする時編集できないことを発見して、間違いは以下の通りです:

   
     
1 >------ Build started: Project: KuanLibTest, Configuration: Release Win32 ------
1 > Compiling...
1 > stdafx.cpp
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 21 ) : error C2039: ' div_t ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 21 ) : error C2873: ' div_t ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 21 ) : error C2039: ' ldiv_t ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 21 ) : error C2873: ' ldiv_t ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 23 ) : error C2039: ' abort ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 23 ) : error C2873: ' abort ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 23 ) : error C2039: ' abs ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 23 ) : error C2873: ' abs ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 24 ) : error C2039: ' atof ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 24 ) : error C2873: ' atof ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 24 ) : error C2039: ' atoi ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 24 ) : error C2873: ' atoi ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 24 ) : error C2039: ' atol ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 24 ) : error C2873: ' atol ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 25 ) : error C2039: ' bsearch ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 25 ) : error C2873: ' bsearch ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 25 ) : error C2039: ' calloc ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 25 ) : error C2873: ' calloc ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 25 ) : error C2039: ' div ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 25 ) : error C2873: ' div ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 26 ) : error C2039: ' exit ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 26 ) : error C2873: ' exit ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 26 ) : error C2039: ' free ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 26 ) : error C2873: ' free ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 26 ) : error C2039: ' getenv ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 26 ) : error C2873: ' getenv ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 27 ) : error C2039: ' labs ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 27 ) : error C2873: ' labs ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 27 ) : error C2039: ' ldiv ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 27 ) : error C2873: ' ldiv ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 27 ) : error C2039: ' malloc ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 27 ) : error C2873: ' malloc ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 28 ) : error C2039: ' mblen ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 28 ) : error C2873: ' mblen ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 28 ) : error C2039: ' mbstowcs ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 28 ) : error C2873: ' mbstowcs ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 28 ) : error C2039: ' mbtowc ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 28 ) : error C2873: ' mbtowc ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 29 ) : error C2039: ' qsort ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 29 ) : error C2873: ' qsort ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 29 ) : error C2039: ' rand ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 29 ) : error C2873: ' rand ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 29 ) : error C2039: ' realloc ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 29 ) : error C2873: ' realloc ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 30 ) : error C2039: ' srand ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 30 ) : error C2873: ' srand ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 30 ) : error C2039: ' strtod ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 30 ) : error C2873: ' strtod ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 30 ) : error C2039: ' strtol ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 30 ) : error C2873: ' strtol ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 31 ) : error C2039: ' strtoul ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 31 ) : error C2873: ' strtoul ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 31 ) : error C2039: ' system ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 31 ) : error C2873: ' system ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 32 ) : error C2039: ' wcstombs ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 32 ) : error C2873: ' wcstombs ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 32 ) : error C2039: ' wctomb ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstdlib( 32 ) : error C2873: ' wctomb ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 19 ) : error C2039: ' memchr ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 19 ) : error C2873: ' memchr ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 19 ) : error C2039: ' memcmp ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 19 ) : error C2873: ' memcmp ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 21 ) : error C2039: ' memset ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 21 ) : error C2873: ' memset ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 22 ) : error C2039: ' strcat ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 22 ) : error C2873: ' strcat ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 22 ) : error C2039: ' strchr ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 22 ) : error C2873: ' strchr ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 22 ) : error C2039: ' strcmp ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 22 ) : error C2873: ' strcmp ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 23 ) : error C2039: ' strcoll ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 23 ) : error C2873: ' strcoll ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 23 ) : error C2039: ' strcpy ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 23 ) : error C2873: ' strcpy ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 23 ) : error C2039: ' strcspn ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 23 ) : error C2873: ' strcspn ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 24 ) : error C2039: ' strerror ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 24 ) : error C2873: ' strerror ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 24 ) : error C2039: ' strlen ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 24 ) : error C2873: ' strlen ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 24 ) : error C2039: ' strncat ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 24 ) : error C2873: ' strncat ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 25 ) : error C2039: ' strncmp ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 25 ) : error C2873: ' strncmp ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 25 ) : error C2039: ' strncpy ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 25 ) : error C2873: ' strncpy ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 25 ) : error C2039: ' strpbrk ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 25 ) : error C2873: ' strpbrk ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 26 ) : error C2039: ' strrchr ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 26 ) : error C2873: ' strrchr ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 26 ) : error C2039: ' strspn ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 26 ) : error C2873: ' strspn ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 26 ) : error C2039: ' strstr ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 26 ) : error C2873: ' strstr ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 27 ) : error C2039: ' strtok ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 27 ) : error C2873: ' strtok ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 27 ) : error C2039: ' strxfrm ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\cstring( 27 ) : error C2873: ' strxfrm ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\exception( 208 ) : error C2039: ' set_terminate ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\exception( 208 ) : error C2873: ' set_terminate ' : symbol cannot be used in a using - declaration
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\exception( 208 ) : error C2039: ' terminate_handler ' : is not a member of ' `global namespace ''
1 > E:\Program Files\Microsoft Visual Studio 9.0 \VC\include\exception( 208 ) : fatal error C1003: error count exceeds 100 ; stopping compilation
1 > Build log was saved at " file://f:\Live Mesh\computer\Coding\fangyukuan\trunk\cpp\kuanlib_test\KuanLibTest\Release\BuildLog.htm "
1 > KuanLibTest - 102 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up - to - date, 0 skipped ==========

 
後で気づいたのは、私が#includeをネーミングスペースに入れたことです.stringにはcstdlibというファイルが含まれています.だから中の関数はこのネーミングスペースに制限されています.他の場所で使用する場合、このネーミングスペースが使用されず、上のコンパイルエラーが発生します.これらは私の推測にすぎない.
私は#includeと他の含むパスをネーミングスペースの外に移動し、コンパイルに合格しました.
 
含まれているパスをネーミングスペースに入れないでください.
もちろん、あるヘッダファイルの定義をあるネーミングスペースに制限したい場合は、リスナーを含むパスをネーミングスペースに入れることができます.実は時々私が名前の衝突を解決するのもこの方法を使っています.
本住所:http://www.cnblogs.com/fangyukuan/archive/2010/06/17/1759757.html