Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Google C++ Style Guide
Forum Updated to NodeBB v4.3 + New Features

Google C++ Style Guide

Scheduled Pinned Locked Moved C++ Gurus
20 Posts 9 Posters 20.4k 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.
  • F Offline
    F Offline
    Franzk
    wrote on last edited by
    #8

    Heh, back to good old plain C again:

    @Object *o = new Object;
    o->init();@

    @struct Object *o = malloc(sizeof(struct Object));
    ObjectInit(o);@

    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peppy
      wrote on last edited by
      #9

      Yes, yes...C# uses it too ((void) Init() functions)

      Google Style Guide is too strict for me...

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

        I think the Google style guide documents the exact mistake a lot of companies make when they are prescribing the style this specifically. Programmers are usually free form thinkers. Putting a too rigid harness on that free form thinking lets developers focus on form rather than on functionality, and frankly, I'd rather have a bit of functionality. If you want to restrict coding rigidly to a certain standard, use a language that isn't as free form as C++.

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Peppy
          wrote on last edited by
          #11

          @Franzk: I totally agree with you.

          [quote author="Franzk" date="1305574936"]Programmers are usually free form thinkers.[/quote]
          I am too ;-)

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leon.anavi
            wrote on last edited by
            #12

            Volker, thanks for sharing! It is always good to know how leading companies work.

            [quote author="Andre" date="1305548881"]Personally, I really like the Qt convention that class names start with a capital, and method names with a lower case letter. That is different in the Google conventions. [/quote]

            Yes it is really nice, although I have to admit that I am still getting used to it :)

            [quote author="Franzk" date="1305574936"]I think the Google style guide documents the exact mistake a lot of companies make when they are prescribing the style this specifically. Programmers are usually free form thinkers. Putting a too rigid harness on that free form thinking lets developers focus on form rather than on functionality, and frankly, I'd rather have a bit of functionality. If you want to restrict coding rigidly to a certain standard, use a language that isn't as free form as C++.[/quote]

            +1 :) Bull's eye! :)

            http://anavi.org/

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Peppy
              wrote on last edited by
              #13

              I prefer Unix or BSD style, it's not so strict as Google has...

              Joke:

              But the best thing that they wrote, was: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=C++0x#C++0x
              " Decision: Use only C++0x libraries and language features that have been approved for use. Currently, no such features are approved. Features will be approved individually as appropriate."
              How can I use C++0x (as it Google said), if there is just specification out?? Think smarter and you'll get nonsense of using this Google Style :D

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

                Preliminary implementations, which is why no libraries at all are approved. But one can hardly expect the trailing comma in enumerators to be a library function.

                @enum HuuHaa {
                Murk, // c++0x specific feature
                };@

                "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

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

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alexander
                  wrote on last edited by
                  #15

                  I wonder, do trolls have analog cpplint.py?:)

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    situ117
                    wrote on last edited by
                    #16

                    http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Inline_Functions

                    Does Qt encourage inline functions inside the library which can be called from user code ? I guess it could cause binary incompatibilities if definition of inline function changes between library versions.

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

                      Inline functions are not strongly en- ord discouraged, but the "Coding Conventions":http://developer.qt.nokia.com/wiki/Coding_Conventions section "Binary and Source Compatibility":http://developer.qt.nokia.com/wiki/Coding_Conventions#017d38d16f3e68ae84e92996ba58c513 requires not to reimplement them (dunno if a change to the code itself would be ok) under certain circumstances.

                      Inline functions an B/C are a special beast, which would lead to use this feature only for short code blocks that are unlikely to change. I second the guidelines of Google here (excluding the -inl.h files).

                      EDIT:
                      To add the Qt counterparts for comparison:

                      • "Qt Coding Conventions":http://developer.qt.nokia.com/wiki/Coding_Conventions
                      • "Qt Coding Style":http://developer.qt.nokia.com/wiki/Qt_Coding_Style

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

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Peppy
                        wrote on last edited by
                        #18

                        Wow, we've got our own coding style, that's nice :D :)

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

                          [quote author="Peppy" date="1305821823"]Wow, we've got our own coding style, that's nice :D :) [/quote]

                          Of course - every good project does have its style guide (or adopts an existing one) :-)

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

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            escorciav
                            wrote on last edited by
                            #20

                            Hi guys,

                            I would like to know how to import the google-style-code in qtcreator, any idea?
                            Is it possible as fast as import or I need to modify a xml file?

                            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