Skip to content
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

implicit casts in API headers must be replaced for C++ support #21365

Closed
pabigot opened this issue Dec 13, 2019 · 4 comments · Fixed by #21391
Closed

implicit casts in API headers must be replaced for C++ support #21365

pabigot opened this issue Dec 13, 2019 · 4 comments · Fixed by #21391
Assignees
Labels
area: C++ bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Milestone

Comments

@pabigot
Copy link
Collaborator

pabigot commented Dec 13, 2019

Various headers take advantage of the fact that C allows implicit casts of void* to other pointer types, e.g.:

..., void* ptr, ....
struct mine *p = ptr;

However this code is erroneous in C++, causing build errors when these headers are included.

Since Zephyr does support C++ in application code, implicit casts should be replaced by explicit casts in any header that provides API to applications.

@pabigot pabigot added bug The issue is a bug, or the PR is fixing a bug area: C++ labels Dec 13, 2019
@pabigot pabigot self-assigned this Dec 13, 2019
@aescolar
Copy link
Member

@pabigot Something like this does indeed make sense to fix. But note that C++ support is quite experimental. So classifying it as a bug, is maybe a bit borderline. So I will set it to low.
(note that we cannot be in a situation where somebody adds some experimental support for a new feature, and we end up blocking all progress anywhere else until that feature is mature enough).

Also note that bug reports like this one are problematic, as it is quite unbound, it does not point to anything in particular, and sets the burden of proof of the bug having been fixed in whoever is fixing it.

@aescolar aescolar added the priority: low Low impact/importance bug label Dec 13, 2019
@stephanosio
Copy link
Member

stephanosio commented Dec 13, 2019

For future reference on the implicit void pointer type conversion error in the C++ compilers:

GCC

  • -fpermissive option can be used to downgrade such errors to warnings.
  • There is no option to disable such warnings.

Clang

  • There is no option to allow an implicit void pointer type conversion.
  • Such a behaviour will always be treated as an error.

@pabigot
Copy link
Collaborator Author

pabigot commented Dec 13, 2019

@aescolar The documentation says nothing about C++ support being "quite experimental" and there are a lot of long-standing bugs related to it, one of which is medium priority, for which we've only just found a viable solution.

I agree the problem is unbound, but I don't see how to focus it. Since we don't have anything that checks conformance on PR submission (not even for things uncrustify can identify) problems will continue to be introduced. Which is why I plan to address this using Coccinelle.

@pabigot pabigot added this to the v2.2.0 milestone Dec 13, 2019
@aescolar
Copy link
Member

Sidetracking

The documentation says nothing about C++ support being "quite experimental"

@pabigot that is probably what we should be fixing first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: C++ bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants