Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How could you disable a .cpp file?
QtWS25 Last Chance

How could you disable a .cpp file?

Scheduled Pinned Locked Moved General and Desktop
16 Posts 9 Posters 5.9k Views
  • 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.
  • F Offline
    F Offline
    fguimaraes
    wrote on last edited by
    #6

    [quote author="leon.anavi" date="1322288172"]
    [quote author="Flurite" date="1322265432"]Okay, thanks, I think I'll stick with commenting it. ;)[/quote]

    Honestly this is the worst solution. It would be better to use a macros.

    [/quote]

    Besides valid, this should not be consider an option at all...

    Birth, death, rebirth, though, and constantly progress, that is the law.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #7

      [quote author="fguimaraes" date="1322497184"][quote author="leon.anavi" date="1322288172"]
      [quote author="Flurite" date="1322265432"]Okay, thanks, I think I'll stick with commenting it. ;)[/quote]

      Honestly this is the worst solution. It would be better to use a macros.

      [/quote]

      Besides valid, this should not be consider an option at all...[/quote]

      Do you refer to commenting or to using macros?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fluca1978
        wrote on last edited by
        #8

        Why not placing a file into a versioning system, and then deleting it until it comes again needed? In this way your code base will be clean (not listing unused files) and you will be able to get it back in the future. I believe it is simpler to not read a file at all than read it and realize it is not used (speaking for the human being part).

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #9

          If you are using an IDE, you might have the possibility to exclude it from compilation (e.g. in Visual Studio). In qt creator you may throw it out from your definition file, but there might be different ways as well.
          The macro and commenting options are certainly valid and I agree with the other responses. Personally I would limit it to section within a file. Commenting for shorter sections and macro for longer.
          However, as you like to exclude a complete file. Why aren't you moving it to subfolder "unused" for example. You may still maintain it in a source management system, but it will be also absolute clear that you are not using at the time. Otherwise it will be come a bit messy with several files not used in the application.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fluca1978
            wrote on last edited by
            #10

            [quote author="koahnig" date="1322498832"]Why aren't you moving it to subfolder "unused" for example. You may still maintain it in a source management system, but it will be also absolute clear that you are not using at the time. Otherwise it will be come a bit messy with several files not used in the application. [/quote]

            My opinion is that this is a CVS-attic like solution, and you will easy get your project messed up since you will loose any information about when, from where and why the file has been moved. I strongly suggest using a good versioning tool.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #11

              [quote author="fluca1978" date="1322500186"]
              My opinion is that this is a CVS-attic like solution, and you will easy get your project messed up since you will loose any information about when, from where and why the file has been moved. I strongly suggest using a good versioning tool.
              [/quote]
              I am using subversion. So no wonder that this might be CVS-attic.
              Which versioning tool would you recommend?

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #12

                I personally prefere to exclude it from the list of files to compile in the project setup (.pro file, visual studio project solution, XCode...) and keep it in the sources.

                @koahnig
                State of the art version control systems are distributed - you benefit from that even as a single developer. The most popular in that domain are "Mercurial":http://mercurial.selenic.com/ (hg), "GIT":http://git-scm.com/ (git) and "Bazaar":http://bazaar.canonical.com/ (bzr). I personally prefer hg, Qt uses git. The principles and features are quite similar, there are some subtle differences, though. You'll have to make your own decision matrix. IIRC there have been some threads on that topic in the forums, better continue discussion there or open a new thread.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  fguimaraes
                  wrote on last edited by
                  #13

                  Volker,

                  Commenting of course! As you said, cutting of the file from .pro (or using macros) are the best solution.

                  Birth, death, rebirth, though, and constantly progress, that is the law.

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    fluca1978
                    wrote on last edited by
                    #14

                    If you are used to svn then mercurial will be simpler to learn, since it has the same version numbering (aside the SHA1) and the concept of commit-a-single-file.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      ddurhamdavyandbeth.com
                      wrote on last edited by
                      #15

                      Instead of #ifdef.. something that makes more sense to me is:

                      #if 0
                      ...
                      #endif

                      Better than /* ... */ because you can nest them.

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        lgeyer
                        wrote on last edited by
                        #16

                        I've never seen code that used macros (#if 0 and alike) or multiline comments to disable large sections of code which wasn't just pure pain to read and understand, especially during code review sessions. It gets even worse if your are forced to use an editor which doesn't support visual suppression of disabled code.

                        It might have its right during immediate development, but every coding guideline should strictly enforce that all disabled code has to be removed as soon as a file is commited. If it needs to be archived a versioning system is the way to go.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved