开发者

How to enable a specific gcc warnings for a specific directory or file? [duplicate]

开发者 https://www.devze.com 2023-03-12 22:54 出处:网络
This question already has answers here:开发者_运维知识库 Closed 11 years ago. Possible Duplicate:
This question already has answers here: 开发者_运维知识库 Closed 11 years ago.

Possible Duplicate:

Selectively disable GCC warnings for only part of a translation unit?

How to enable a specific gcc warnings for a specific directory or file ?

I want to enable -Wsign-conversion for my own files not for any other system headers


This line should do it: (see here)
#pragma GCC diagnostic warning "-Wsign-conversion"

Put it in the affected files or in a header that is included in all you files


If you want to do it outside of your source file, then you need to reference your build system. E.g. in make you can always specify a direct target in the Makefile:

foo.o: foo.c
    $(CC) -o $> -Wsign-conversion $<

This will take precedence to a general .c->.o rule as it is more more specific.

Other build systems have other methods of achieving the same rule.

In short, your question is really about your build system, and not about gcc.

0

精彩评论

暂无评论...
验证码 换一张
取 消