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. Error : Windows.h already defined .

Error : Windows.h already defined .

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorial
9 Posts 5 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.
  • J Offline
    J Offline
    Jhony george
    wrote on last edited by
    #1

    hai.dear. i opened win32 application...and i had 3 cpp files which reqd windows.h ...so i added windows.h in win32 files... now i have one cpp file which is mfc support file..mfc support means using Cstring datatype..and AFxBeginthread and some other also... so..now i have added that mfc support cpp file to my project... which is having header files #include afx.h #include afxwin.h and etc..related to mfc.. now i builded my program...it is throwing this error... fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include what to do for this error..how to solve this..

    N N 2 Replies Last reply
    0
    • J Jhony george

      hai.dear. i opened win32 application...and i had 3 cpp files which reqd windows.h ...so i added windows.h in win32 files... now i have one cpp file which is mfc support file..mfc support means using Cstring datatype..and AFxBeginthread and some other also... so..now i have added that mfc support cpp file to my project... which is having header files #include afx.h #include afxwin.h and etc..related to mfc.. now i builded my program...it is throwing this error... fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include what to do for this error..how to solve this..

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #2

      Remove the windows.h and use the afxwin.h

      - NS -

      J 1 Reply Last reply
      0
      • N Nishad S

        Remove the windows.h and use the afxwin.h

        - NS -

        J Offline
        J Offline
        Jhony george
        wrote on last edited by
        #3

        hai.. already i tried this.., still it is throwing error. becos i am using MSMQ in my project. it requires mq.h header file. this requires the windows.h header file.

        N D 2 Replies Last reply
        0
        • J Jhony george

          hai.. already i tried this.., still it is throwing error. becos i am using MSMQ in my project. it requires mq.h header file. this requires the windows.h header file.

          N Offline
          N Offline
          Nishad S
          wrote on last edited by
          #4

          But afxwin.h includes the windows.h

          - NS -

          1 Reply Last reply
          0
          • J Jhony george

            hai.dear. i opened win32 application...and i had 3 cpp files which reqd windows.h ...so i added windows.h in win32 files... now i have one cpp file which is mfc support file..mfc support means using Cstring datatype..and AFxBeginthread and some other also... so..now i have added that mfc support cpp file to my project... which is having header files #include afx.h #include afxwin.h and etc..related to mfc.. now i builded my program...it is throwing this error... fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include what to do for this error..how to solve this..

            N Offline
            N Offline
            Nelek
            wrote on last edited by
            #5

            use #pragma once or ifndef / ifdef precompiler instructions to avoid repetitions

            Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

            T 1 Reply Last reply
            0
            • N Nelek

              use #pragma once or ifndef / ifdef precompiler instructions to avoid repetitions

              Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              Nelek wrote:

              use #pragma once or ifndef / ifdef precompiler instructions to avoid repetitions

              mfc doesn't allow you to include Windows.h with it! so ifndef/ifdef will be of no use!

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
              Never mind - my own stupidity is the source of every "problem" - Mixture

              cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

              N 1 Reply Last reply
              0
              • T ThatsAlok

                Nelek wrote:

                use #pragma once or ifndef / ifdef precompiler instructions to avoid repetitions

                mfc doesn't allow you to include Windows.h with it! so ifndef/ifdef will be of no use!

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                Never mind - my own stupidity is the source of every "problem" - Mixture

                cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

                N Offline
                N Offline
                Nelek
                wrote on last edited by
                #7

                Ahhhmmm :doh: the assistant include these by default.

                #include < afxwin.h > // MFC-Kern- und -Standardkomponenten
                #include < afxext.h > // MFC-Erweiterungen
                #include < afxdisp.h > // MFC Automatisierungsklassen
                #include < afxdtctl.h > // MFC-Unterstützung für allgemeine Steuerelemente von Internet Explorer 4
                #ifndef _AFX_NO_AFXCMN_SUPPORT
                #include < afxcmn.h > // MFC-Unterstützung für gängige Windows-Steuerelemente
                #endif // _AFX_NO_AFXCMN_SUPPORT

                and with this it is supposed to have the most of the "standard" MFC functionality, isn't it? Maybe adding one of them....

                Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

                T 1 Reply Last reply
                0
                • N Nelek

                  Ahhhmmm :doh: the assistant include these by default.

                  #include < afxwin.h > // MFC-Kern- und -Standardkomponenten
                  #include < afxext.h > // MFC-Erweiterungen
                  #include < afxdisp.h > // MFC Automatisierungsklassen
                  #include < afxdtctl.h > // MFC-Unterstützung für allgemeine Steuerelemente von Internet Explorer 4
                  #ifndef _AFX_NO_AFXCMN_SUPPORT
                  #include < afxcmn.h > // MFC-Unterstützung für gängige Windows-Steuerelemente
                  #endif // _AFX_NO_AFXCMN_SUPPORT

                  and with this it is supposed to have the most of the "standard" MFC functionality, isn't it? Maybe adding one of them....

                  Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)

                  T Offline
                  T Offline
                  ThatsAlok
                  wrote on last edited by
                  #8

                  yeap you are right

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                  Never mind - my own stupidity is the source of every "problem" - Mixture

                  cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

                  1 Reply Last reply
                  0
                  • J Jhony george

                    hai.. already i tried this.., still it is throwing error. becos i am using MSMQ in my project. it requires mq.h header file. this requires the windows.h header file.

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    D.Mani wrote:

                    it requires mq.h header file.

                    So include that in the project's stdafx.h file, below the Afx-related includes.


                    "A good athlete is the result of a good and worthy opponent." - David Crow

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    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