Surpress compiler warnings?

I am using VS Code and there is a growing list of warnings that I would prefer to just not see. I have tried adding compiler args of “-Wno-unknown-pragmas” and “Wno-unused” but it seems to make no difference.

Any pro tips?

Never suppress warnings. If the warnings are in your code, fix the code to remove the warnings. If the warnings are in a library, get the library developer to fix their code or get another library. Ignorance is not bliss.

2 Likes

It isn’t ignorance. Don’t need some rando opinion, if you can’t add anything just stay quiet.

You asked for a pro tip. I have been a professional firmware developer for over 40 years. It is considered industry best practice to never suppress warnings. Your code should compile cleanly every time, or you fix it until it does. Don’t ignore warnings.

6 Likes

I get that it is best practice. However, vscode supports code folding in C++ using #pragma region. I prefer it to keep things nice and neat. In a standard C++ project in vscode I can suppress the warning for that. However, the standard place I would set those flags isn’t working, so I am asking where I would set those flags? I would prefer not to scroll around to find the actual error the output 99% of the time.

While I agree that turning warnings off is never a good idea, have you tried to suggestions in this Stack Overflow post?

It looks like 4068 is the magic number.

Yes, I have, but it seems to have no effect. I was guessing that maybe the make process the particle SDK uses is bypassing something. Even if I have it in the file itself, it seems to show all the warnings.

You can find the Makefile used by Workbench at ~/.particle/toolchains/buildscripts/1.10.0/Makefile

You can put additional flags in the EXTRA_CFLAGS environment variable.

export EXTRA_CFLAGS="-Wno-unknown-pragmas -Wno-unused"

Also if you’re interested in a complementary tool/replacement for Workbench I’d recommend checking out neopo. It’s python-based and can be used in many environments.

Adding additional flags to a project is supported with the neopo flags command:

$ neopo flags "-Wno-unknown-pragmas -Wno-unused"
$ neopo build

Thank you nrobinson2000, I think we are getting closer. I still get all of the warnings, but I now see this message right before it finishes compiling:

cc1plus: note: unrecognized command-line option ‘-Wno-unknown-pragmas -Wno-unused’ may have been intended to silence earlier diagnostics