Ask Your Question
2

Can one pick specific variables to avoid receiving "false" positive warnings for unused variables while using the "-Wall" flag on the gcc compiler?

asked 2023-05-30 01:56:29 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-05-30 02:04:02 +0000

huitzilopochtli gravatar image

Yes, one can use the "attribute((unused))" directive to inform the compiler that a specific variable may be unused, and thus avoid receiving false positive warnings for that variable when using the "-Wall" flag. For example:

int main() {
    int x attribute((unused));   // inform compiler that x may be unused
    return 0;
}

This will inform the compiler that the variable "x" may be unused and prevent false positive warnings for that variable.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-30 01:56:29 +0000

Seen: 5 times

Last updated: May 30 '23