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. Qt Creator, syntax checking do not recognize gcc extensions.

Qt Creator, syntax checking do not recognize gcc extensions.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.2k 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.
  • X Offline
    X Offline
    xtech
    wrote on 3 Dec 2016, 11:27 last edited by xtech 12 Mar 2016, 13:24
    #1

    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.

    K 1 Reply Last reply 3 Dec 2016, 20:05
    0
    • X xtech
      3 Dec 2016, 11:27

      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.

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 3 Dec 2016, 20:05 last edited by
      #2

      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 4 Dec 2016, 10:01
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 4 Dec 2016, 08:12 last edited by mrjj 12 Apr 2016, 08:13
        #3

        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
        1
        • K kshegunov
          3 Dec 2016, 20:05

          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
          
          X Offline
          X Offline
          xtech
          wrote on 4 Dec 2016, 10:01 last edited by xtech 12 Apr 2016, 10:01
          #4

          @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,

          K 1 Reply Last reply 4 Dec 2016, 12:44
          0
          • X xtech
            4 Dec 2016, 10:01

            @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,

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 4 Dec 2016, 12:44 last edited by
            #5

            @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
            0

            1/5

            3 Dec 2016, 11:27

            • Login

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