-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show warnings only for open blocks #18
Comments
I am trying to do so, and added the SYSTEM option to all our TARGET_INCLUDE_DIRECTORIES, but doesnt seem to have the desired effect. BTW, just in case you also want to try out things, there is always the option of running from source, it is not difficult to setup, and you will manage to run patches and fixes before the next release. But for the installed/compiled version, you can also hack the biicode.cmake template file. It is located in your installation => bii\biicode\client\dev\cpp\cmake folder. You can try to modify it, it will be used in your bii commands and projects. Just make sure to backup and restore it. What I have tried is to add the SYSTEM option to all target_include_directories there, so it is actually being used for all includes, and still the warnings are propagated, will keep investigating. |
I have figured out how to do it, but only for non absolute paths, i.e. not for #include "user/block/header.h" but for #include "header.h" and adding an [includes] with header.h: user/block. Also I am configuring it as a opt-in functionality, as it breaks arduino builds. Are you using absolute or relative paths? |
For my blocks to work with simple project layout (on travis), I have to use absolute paths when including other blocks. Paths inside a block are relative, but this is my code, so I want to get the warnings. How did you solve it? I'm wondering because it seems to be a compiler feature meant for system libraries, which usually are included using absolute paths as well. Opt-in is fine for me. |
ah I misunderstood your last post - didn't see the thing about using the [includes] section before. What is the problem with absolute paths? Do relative paths in subfolders work ("folder/header.h")? |
The current problem with absolute path, in order to achieve this SYSTEM Relative include paths, those defined by [includes] and [paths] are added Includes to other blocks can indeed be relative, using the [includes] [includes] Wildcard patterns are allowed (gtest/*.h: google/gtest/include). This is Diego Rodriguez-Losada 2015-05-03 16:53 GMT+02:00 Sebastian Meßmer [email protected]:
|
Thanks for the detailed explanation, that makes sense. If I understood you correctly, the problem with absolute paths is that biicode.conf isn't processed yet when adding them to include_directories. Maybe a solution could be to define opt-in/opt-out behavior not in biicode.conf, but somewhere else? Say settings.bii? I'm not sure which is the better place anyhow. I'd like to have it in biicode.conf, so I don't have to reconfigure it per build client, but on the other hand this configuration might be a client decision that is/should be independent from the actual source code. |
Hi Sebastian! I have just pushed it to develop (you can use it from source, will be in next release): 92d9e4d To summarize:
If you try it from source, or when next release is out, could you please tell me if it worked? Thanks! |
Just tested it from your develop branch. It works like a charm. This really improves my ability to keep my code clean, thanks you so much :) One possibility for improvement: Also use this for boost libraries. When using the biicode/boost/setup repository with "-Wall -Wextra", I get a lot of warnings from boost (for example .biicode/boost/1.57.0/boost/spirit/home/classic/utility/functor_parser.hpp) |
You are welcome :) that was a good suggestion, I also dislike so many warnings when building deps. The boost libraries are handled a bit differently, probably @Manu343726 who developed that block can have a look at it. |
(see http://forum.biicode.com/t/show-warnings-only-for-open-blocks/334 )
I'd like to use warning flags like "-Wall -Wextra -Weffc++" on my code, but using
shows a lot of warnings for the blocks I'm including (e.g. boost).
Reasoning
I generally assume the libraries I use are working, but might not be written using good C++ style. Some libraries might be written well, but still throw warnings on -Weffc++, because they use certain constructs for performance (e.g. boost often doesn't have virtual destructors on inherited classes).
As a developer using an arbitrary library, it is not necessarily my task to remove the warnings from their code (which might sometimes not be possible like in the boost example above), but I'd like to use the warnings mechanism to be notified of style issues in my own code. Warnings in code written by others just clutters the output and makes it harder for me to find the issues in my own code.
Many languages (e.g. Java, Scala, ...) only show you warnings in your own code and I think that this generally is the better approach. But because of the C++ header inclusion mechanism, compilers can't easily distinguish whether you're including a header you've written yourself or a header from a library.
They actually can distinguish whether you're including a system header, and in this case, they also hide the warnings from there. But they can't easily distinguish 3rd party library headers from your own headers (the 3rd party library might just be in some subfolder of your project for example).
Different to plain compilers, biicode is in a position to easily decide whether a header is a 3rd party header or not (open blocks are own code, closed blocks 3rd party). So biicode might have the chance here to be better than previous systems.
Since this is a behavior C++ programmers might not be used to, an opt-in or opt-out could be offered. I'll definitely opt-in, because I think it is much better behavior.
Possible implementation
I've read that including other libraries as system libraries makes gcc ignore warnings for these library headers. This could for example be done with
Is it possible to include closed blocks this way and therefore make gcc only show warnings for open blocks?
The text was updated successfully, but these errors were encountered: