Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to solve this compiler error.

How to solve this compiler error.

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcsharpvisual-studiolinux
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pankajkumar
    wrote on last edited by
    #1

    Dear Programmers, I converted a linux code to vc++ MFC app(VS2012), compiler generating this error on compilation:- 1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2039: 'fclose' : is not a member of '`global namespace'' 1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2873: 'fclose' : symbol cannot be used in a using-declaration. Though have tried several setting changes, but this error is upsetting. Any help would be highly appreciated. -Pankaj

    J V 2 Replies Last reply
    0
    • P pankajkumar

      Dear Programmers, I converted a linux code to vc++ MFC app(VS2012), compiler generating this error on compilation:- 1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2039: 'fclose' : is not a member of '`global namespace'' 1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2873: 'fclose' : symbol cannot be used in a using-declaration. Though have tried several setting changes, but this error is upsetting. Any help would be highly appreciated. -Pankaj

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      This may occur when the source file is compiled as C. If it is a plain C file (.c) you should not include cstdio but stdio.h. If it is a C++ file (or should be compiled as such), set the appropriate option in the project settings (I have no VS21012 here but it should be at "C/C++ - Advanced" - "Compile As") to compile all files as C++, or rename source files to .cpp.

      P 1 Reply Last reply
      0
      • P pankajkumar

        Dear Programmers, I converted a linux code to vc++ MFC app(VS2012), compiler generating this error on compilation:- 1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2039: 'fclose' : is not a member of '`global namespace'' 1>c:\program files (x86)\microsoft visual studio 11.0\vc\include\cstdio(39): error C2873: 'fclose' : symbol cannot be used in a using-declaration. Though have tried several setting changes, but this error is upsetting. Any help would be highly appreciated. -Pankaj

        V Offline
        V Offline
        Victor Nijegorodov
        wrote on last edited by
        #3

        Unfortunately you haven't shown the code causng these errors, so can only guess... Try to google for these errors ... so you would find something like [c++ - function is not a member of global namespace - Stack Overflow](https://stackoverflow.com/questions/21842142/function-is-not-a-member-of-global-namespace)

        P 1 Reply Last reply
        0
        • J Jochen Arndt

          This may occur when the source file is compiled as C. If it is a plain C file (.c) you should not include cstdio but stdio.h. If it is a C++ file (or should be compiled as such), set the appropriate option in the project settings (I have no VS21012 here but it should be at "C/C++ - Advanced" - "Compile As") to compile all files as C++, or rename source files to .cpp.

          P Offline
          P Offline
          pankajkumar
          wrote on last edited by
          #4

          Dear I have done it several times, but same errors are getting produced. Problem is not with code...problem is if vc++ 2012 compiler IDE... Am I missing some library/ switch..? -Pankaj

          J 1 Reply Last reply
          0
          • V Victor Nijegorodov

            Unfortunately you haven't shown the code causng these errors, so can only guess... Try to google for these errors ... so you would find something like [c++ - function is not a member of global namespace - Stack Overflow](https://stackoverflow.com/questions/21842142/function-is-not-a-member-of-global-namespace)

            P Offline
            P Offline
            pankajkumar
            wrote on last edited by
            #5

            Dear programmer, Code does not have any issue...VS 2012 IDE setting has... Even I posted same problem in several boards..a programmer suggested that I should make a simple program on Visual C++ 2012 IDE, with . I made a simple app with only ..(library/header...namespace as documentation says of microsoft). Again same error on compilation... 1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cstdio(39): error C2039: 'fclose' : is not a member of '`global namespace'' 1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cstdio(39): error C2873: 'fclose' : symbol cannot be used in a using-declaration ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========.. Am i missing some setting..? -Pankaj

            P 1 Reply Last reply
            0
            • P pankajkumar

              Dear I have done it several times, but same errors are getting produced. Problem is not with code...problem is if vc++ 2012 compiler IDE... Am I missing some library/ switch..? -Pankaj

              J Offline
              J Offline
              Jochen Arndt
              wrote on last edited by
              #6

              I can't really help without knowing what you are doing and do not have VS2012 here. But this should compile (console project with pre-compiled headers):

              #include "stdafx.h"
              // stadfx.h:
              // Sets WINVER and _WIN32_WINNT
              // #include <windows.h>
              // #include <tchar.h>
              #include

              int _tmain(int argc, _TCHAR* argv[])
              {
              // May also use ::fopen() and ::fclose() instead
              FILE *f = fopen(_T("test"), _T("r"));
              fclose(f);
              return 0;
              }

              1 Reply Last reply
              0
              • P pankajkumar

                Dear programmer, Code does not have any issue...VS 2012 IDE setting has... Even I posted same problem in several boards..a programmer suggested that I should make a simple program on Visual C++ 2012 IDE, with . I made a simple app with only ..(library/header...namespace as documentation says of microsoft). Again same error on compilation... 1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cstdio(39): error C2039: 'fclose' : is not a member of '`global namespace'' 1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\cstdio(39): error C2873: 'fclose' : symbol cannot be used in a using-declaration ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========.. Am i missing some setting..? -Pankaj

                P Offline
                P Offline
                pankajkumar
                wrote on last edited by
                #7

                I used VC++ 2008...there is not as much fussy issue, as VC++ 2012 is producing(useless hurdles)....program itself has complex logic... Issue is closed..I changed environmnt vc++ 2008..

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups