Thanks to visit codestin.com
Credit goes to github.com

Skip to content

simplecpp.cpp: Issue error when an explicitly included file is not found#184

Merged
danmar merged 4 commits into
cppcheck-opensource:masterfrom
versat:add_error_on_missing_include
Dec 7, 2019
Merged

simplecpp.cpp: Issue error when an explicitly included file is not found#184
danmar merged 4 commits into
cppcheck-opensource:masterfrom
versat:add_error_on_missing_include

Conversation

@versat

@versat versat commented Dec 6, 2019

Copy link
Copy Markdown
Contributor

If a file is explicitly included for example via command line option
-include= but can not be opened this error message is issued now.
Example:
$ ./simplecpp -include=blah.h foo.c
int main ( )
{
return 0 ;
}
foo.c:1: missing header: Can not open include file 'blah.h' that is explicitly included for all files.

Fixes #183

If a file is explicitly included for example via command line option
`-include=` but can not be opened this error message is issued now.
Example:
$ ./simplecpp -include=blah.h foo.c
int main ( )
{
return 0 ;
}
foo.c:1: missing header: Can not open include file 'blah.h' that is explicitly included for all files.

Fixes cppcheck-opensource#183
Comment thread simplecpp.cpp Outdated
@versat

versat commented Dec 6, 2019

Copy link
Copy Markdown
Contributor Author

Hmm, while this works for simplecpp, this is not a solution for Cppcheck.
In Cppcheck outputList is NULL, so it does not make any difference.

EDIT: Nevermind, I have found out why. Cppcheck only uses an outputList for preprocessing, not for loading yet.

`MISSING_HEADER` is only meant as an information to the user, nothing
really relevant while this issue reveals a problem with the command
line options that should get fixed.

@danmar danmar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! Just make small tweaks!

Comment thread simplecpp.cpp Outdated
Comment thread simplecpp.cpp Outdated
@versat

versat commented Dec 7, 2019

Copy link
Copy Markdown
Contributor Author

Sorry, I had no better idea than EXPLICIT_INCLUDE_NOT_FOUND as new error type. Do you have any better idea? I have thought about PARAMETER_ERROR or something like that, but I am not sure if that is too generic or not.

@danmar

danmar commented Dec 7, 2019

Copy link
Copy Markdown
Collaborator

Do you have any better idea?

Not directly. Let's use this for now.. it's ok to change it later.

@danmar danmar merged commit c27e5d4 into cppcheck-opensource:master Dec 7, 2019
@versat versat deleted the add_error_on_missing_include branch December 9, 2019 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

simplecpp silently ignores when an explicitly included file does not exist

2 participants