Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Qt Creator, syntax checking do not recognize gcc extensions.

    General and Desktop
    3
    5
    971
    Loading More Posts
    • 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.
    • X
      xtech last edited by xtech

      Is there any way to turn off or add special case to Qt Creator syntax checking? I ask because now when I use for example gcc "Case Ranges" extension like

      switch( size ) {
          case 1:
              // do x
          break;
          case 2 ... 255:
              // do y
          break;
          case 256 ... 512:
              // do z
          break;
      }
      

      0_1480771471865_upload-ba18a049-62e7-4249-afe1-4c0a6816fe76

      Qt Creator 4.1.1 show red underline warning which disturb reading code.

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @xtech last edited by

        I don't think you can fix the underline in creator, no. Why not use a simple if-else and not rely on non-standard extensions?

        if (size == 1)
            // do x
        else if (size >= 2 && size <= 255)
           // do y
        // ... and so on
        

        Read and abide by the Qt Code of Conduct

        X 1 Reply Last reply Reply Quote 1
        • mrjj
          mrjj Lifetime Qt Champion last edited by mrjj

          Hi
          I support @kshegunov recommendation to not use those extensions.
          However, there is the following feature
          (Tools->Options menu)
          alt text

          You can change how the error underlining should look and hence also remove it.
          Simply COPY the color theme and u can alter it.

          However this applies to all cases so not optimal but its still marked in the side so
          you are not killing the feature completely.

          1 Reply Last reply Reply Quote 1
          • X
            xtech @kshegunov last edited by xtech

            @kshegunov

            Because as far as I know, switch can be sometimes better optimized by compiler and for me switch is more readable but it is a matter of taste.

            I also think that this extension should be in standard, but that is another matter.
            I report this behavior of Qt Creator to Qt Team as suggestion maybe it something will change...

            Thanks all,

            kshegunov 1 Reply Last reply Reply Quote 0
            • kshegunov
              kshegunov Moderators @xtech last edited by

              @xtech said in Qt Creator, syntax checking do not recognize gcc extensions.:

              Because as far as I know, switch can be sometimes better optimized by compiler

              Not in this particular case.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply Reply Quote 0
              • First post
                Last post