This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

diagnostic suppression for a few lines

Hello 

Is there a way to suppress diagnostic for for a few lines. 

With the #pragma diag_suppress = 552 seems to work just for the whole file.

Regards Reto

  • Hi,

    As long as I know you can only do that for a whole file, because its an option passed to the compiler. Maybe, if you want to disable the warning for just a specific function, you could put only that function in a file and disable the warning for it.

    BR

    J

  • Reto said:

    Is there a way to suppress diagnostic for for a few lines. 

    With the #pragma diag_suppress = 552 seems to work just for the whole file.

    Use #pragma diag_default id_number to change the level of a diagnostic back to the compiler default.  Something like this ...

        #pragma diag_suppress 552
        // lines that cause the diagnostic here
        #pragma diag_default 552
    

    The compiler tips and tricks presentations include a section on Compiler Diagnostics with tips like this.

    Thanks and regards,

    -George

  • Setting back with the default I already tried out. Then the occurs again. It looks as if the last pragma in file defines the whole file behavior.

  • I'm confused.  Isn't this what you expect?  Please show an example of what you are doing, and describe in detail how it does not behave as you expect.

    Thanks and regards,

    -George

  • #pragma diag_suppress 552
    static DT_BOOL HallSensorSignal[3] = {DT_FALSE, DT_FALSE, DT_FALSE};
    #pragma diag_default 552

    When I use the code the warning is still there. The warning just disappears when I not use the #pragma diag_default 552. But I need the warnings for the other lines. I'm using c2000 tools with the compiler 6.1.4.

  • I couldn't reproduce diagnostic 552 based on the one source line you show here.  I finally looked it up here.  Now I understand the nature of your complaint.  In summary, there is no clean solution.  I'll try to explain.

    Diagnostic 552 says: variable name is set but never used.  It is different from most other diagnostics in that it is associated with a specific variable and not specific source line.  For that reason, the #pragma method of controlling it doesn't work.  The #pragma method controls whether you see a specific diagnostic across some range of source lines.  There is no method to control the few diagnostics associated with a variable.  Attempting to use the #pragma method only shows, as you have seen, that it doesn't really work.

    Thanks and regards,

    -George