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 properly create and use project files

how to properly create and use project files

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestiondata-structurestutorial
7 Posts 4 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.
  • G Offline
    G Offline
    gazihan
    wrote on last edited by
    #1

    Hi, I'm a bit new to visual c++ and i'm trying to figure out the right style to create and use new .h and .cpp files in vc++. Say I want to implement a new module of the project in a seperate file. And say I created the new.h and new.cpp files. Now the question is, how should I set the #include lines in the entire project in order to make it work? In new.cpp, I want to use the libraries included in stdafx.h. And in the other parts of the application that stadfx.h is included, I want to use the code that resides in new.cpp. I tried many different ways of including one another but I couldn't find an appropriate one. It either tels me that in my new.cpp file, "unexpected end of file while looking for precompiled header directive" error is present, or it reports multiple definitions. :confused: I think you got what I'm trying to do, so pls help me how to set the include graph thorughout my application. Thanx in advance.

    J R 2 Replies Last reply
    0
    • G gazihan

      Hi, I'm a bit new to visual c++ and i'm trying to figure out the right style to create and use new .h and .cpp files in vc++. Say I want to implement a new module of the project in a seperate file. And say I created the new.h and new.cpp files. Now the question is, how should I set the #include lines in the entire project in order to make it work? In new.cpp, I want to use the libraries included in stdafx.h. And in the other parts of the application that stadfx.h is included, I want to use the code that resides in new.cpp. I tried many different ways of including one another but I couldn't find an appropriate one. It either tels me that in my new.cpp file, "unexpected end of file while looking for precompiled header directive" error is present, or it reports multiple definitions. :confused: I think you got what I'm trying to do, so pls help me how to set the include graph thorughout my application. Thanx in advance.

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      #include "stdafx.h" must be the first #include of all, always. Apart from this, include the new header in those .cpps that require it. If your new module is used by many other parts throughout the libvrary, you can edit stdafx.h and add the #include there. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      G 1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        #include "stdafx.h" must be the first #include of all, always. Apart from this, include the new header in those .cpps that require it. If your new module is used by many other parts throughout the libvrary, you can edit stdafx.h and add the #include there. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        G Offline
        G Offline
        gazihan
        wrote on last edited by
        #3

        Ok I see now. new.h includes nothing, new.cpp includes new.h and stdafx.h, and stdafx.h includes new.h. new.cpp is automatically built with other cpps. Thanx again.:-O

        N 1 Reply Last reply
        0
        • G gazihan

          Ok I see now. new.h includes nothing, new.cpp includes new.h and stdafx.h, and stdafx.h includes new.h. new.cpp is automatically built with other cpps. Thanx again.:-O

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          gazihan wrote: stdafx.h includes new.h No! stdafx.h includes common header files used by all cpp files Nish


          Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

          G 1 Reply Last reply
          0
          • N Nish Nishant

            gazihan wrote: stdafx.h includes new.h No! stdafx.h includes common header files used by all cpp files Nish


            Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

            G Offline
            G Offline
            gazihan
            wrote on last edited by
            #5

            the stdafx.h has this line: // TODO: reference additional headers your program requires here I want to use new.h in most of the cpp files, so I guess what I did is apropriate.

            N 1 Reply Last reply
            0
            • G gazihan

              Hi, I'm a bit new to visual c++ and i'm trying to figure out the right style to create and use new .h and .cpp files in vc++. Say I want to implement a new module of the project in a seperate file. And say I created the new.h and new.cpp files. Now the question is, how should I set the #include lines in the entire project in order to make it work? In new.cpp, I want to use the libraries included in stdafx.h. And in the other parts of the application that stadfx.h is included, I want to use the code that resides in new.cpp. I tried many different ways of including one another but I couldn't find an appropriate one. It either tels me that in my new.cpp file, "unexpected end of file while looking for precompiled header directive" error is present, or it reports multiple definitions. :confused: I think you got what I'm trying to do, so pls help me how to set the include graph thorughout my application. Thanx in advance.

              R Offline
              R Offline
              Rage
              wrote on last edited by
              #6

              gazihan wrote: "unexpected end of file while looking for precompiled header directive" this error can usually be avoided by changing in Project/Settings/C C++ tab Select a .cpp in the tree left Category : Precompiled Header Set it to Dont'use ... But do not do that for stdafx.cpp of course :) ~RaGE();

              1 Reply Last reply
              0
              • G gazihan

                the stdafx.h has this line: // TODO: reference additional headers your program requires here I want to use new.h in most of the cpp files, so I guess what I did is apropriate.

                N Offline
                N Offline
                Nish Nishant
                wrote on last edited by
                #7

                gazihan wrote: I want to use new.h in most of the cpp files, so I guess what I did is apropriate. Okay! If you are including new.h inside stdafx.h, then do not include new.h in any of your cpp files, since by including stdafx.h you implicitly include new.h as well. Regards Nish


                Author of the romantic comedy Summer Love and Some more Cricket [New Win] Buy it, read it and admire me :-)

                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