Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Qt.io webservices
  4. Mistake in docs. "Qt Coding Conventions" section
Qt 6.11 is out! See what's new in the release blog

Mistake in docs. "Qt Coding Conventions" section

Scheduled Pinned Locked Moved Qt.io webservices
1 Posts 1 Posters 1.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.
  • O Offline
    O Offline
    OLLO
    wrote on last edited by
    #1

    It's not in one place, "Qt Coding Conventions":http://qt-project.org/wiki/Coding-Conventions , but others("example":http://qt.gitorious.org/qt-creator/qt-creator/blobs/8a2aab79e9db6a6bf0c179e8e84a812d0c1b62c1/doc/api/coding-style.qdoc) seems just copy of that.
    In the end

    @Always check whether a preprocessor variable is defined before probing its value (-Wundef)

        #if Foo ==  0  // W R O N G *first*
    
        #if defined(Foo) && Foo ==  0 // Right *second*
    
        #if Foo - 0 ==  0 // Clever, are we? Use the one above instead, for better readability *third*@
    

    But if Foo is undefined second is false and third is true, because all undefined identifiers are replaced with literal 0. I checked this will latest Qt Creator and it act so.

    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