Qt Creator, syntax checking do not recognize gcc extensions.



  • 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.


  • Qt Champions 2016

    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
    

  • Qt Champions 2016

    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.



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


  • Qt Champions 2016

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.