-
Notifications
You must be signed in to change notification settings - Fork 3k
Give an option to remove 'using namespace' #7760
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
Conversation
Looks conceptually good to me. Is the intent then that application code would either define this Little bit doubtful about the name - it's more There is another possible alternative approach. You could do what the C++ library does and make it so that That is a pattern I've not seen outside the standard C++ library, but given that it's there it shouldn't be totally unfamiliar. But it doesn't match our use of Maybe |
I like the idea but I fear it confuses some of our developers. Our codebase itself is not consistent with the practice. For the name, like @kjbracey-arm I think it should be changed. What's the path going forward ? Is there a plan to set this macro by default ? It may be worthwhile to think of how components are mapped into namespaces as we may require more than just the mbed namespace. |
Can leave that to application. It should work both ways, if we make sure mbed-os compiles with flag enabled globally. Default we cannot enable it, but adding it to CI or not will be question.
Yes , good names are appreciated.
Agree with @pan- it will be confusing, Also as you mentioned it will not be backward compatible we should avoid that solution. |
As a user, I agree with not dropping the
How about for Mbed OS 6.0? Or, zooming out, why is @pan- said previously (#5679 (comment)):
|
cde3907
to
3192560
Compare
My understanding is that it's desirable for "simplicity" - simple apps just include "mbed.h". Same basic argument as putting every single folder on the include path, and putting everything in the global namespace. Also, possibly some of the core built-in stuff doesn't have as obviously clear "what to include" rules as "Thread.h" for I would say it should not be used in any OS or library header files, so that the name pollution isn't forced on application code. |
events/mbed_shared_queues.cpp
Outdated
@@ -15,7 +15,10 @@ | |||
*/ | |||
|
|||
#include "events/mbed_shared_queues.h" | |||
#include "mbed.h" | |||
|
|||
#ifdef MBED_CONF_RTOS_PRESENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see similar changes in this PR that could be separated from adding new config (changes in events files at least)? As I expect with this config change to touch only mbed or std namespace (add it ,remove it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing namespace i.e building mbed-os with "-DMBED_NO_GLOBAL_USING_DIRECTIVE" results in build failures as 'mbed.h' added here will not add RTOS / Mbed namespace in cpp files as well.
This cleanup "i.e. add only required namespace/header file" is needed for removal of namespace to work. I can add it as separate PR, and make this PR to be dependent on that.
@kjbracey-arm,
I absolutely agree. Assuming you do keep it, please also document in appropriate places (when it becomes true) that application code doesn't need to |
ced54da
to
7765de7
Compare
👍 Removing mbed.h here - #7864 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@deepikabhavnani All storage PR landed, or still waiting for some here? |
Review from storage team is pending as well |
@offirko can you please review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no remarks, LGTM.
All the PRs need to be engineering ready (marked as "needs: CI") by the end of the day (Austin time). Otherwise it won't make 5.11 and will need to come in the next release (5.12 for features, 5.11.1 for fixes and new platforms). |
…mespace Macro guard `MBED_NO_GLOBAL_USING_DIRECTIVE` is added around namespace, to avoid polluting users namespace.
26a3d12
to
d54e682
Compare
Rebased |
CI started. |
Adding new modules inside the namespace could be breaking change for existing code base hence add `using namespace::class` for classes newly added to mbed namespace to maintian backwards compatibility. MBED_NO_GLOBAL_USING_DIRECTIVE is added to remove auto-addition of namespace Macro guard `MBED_NO_GLOBAL_USING_DIRECTIVE` is added around namespace, to avoid polluting users namespace.
d54e682
to
da69da9
Compare
@cmonr - Fixed for failing device. Needs CI restart |
I like it. So fast, didn't even realize this had a problem. CI restarted. |
Test run: SUCCESSSummary: 4 of 4 test jobs passed |
Description
DO NOT MERGEI have created this PR to get input from all teams for solution to namespace issue.
Purpose:
MBED_NO_NAMESPACE
macrombed
namespace. Addition of existing classes inside mbed namespace breaks compatibility, hence below code should be added to maintain compatibility.List of all classes to be moved to
mbed
namespace. Feel free to add to the list or comment below if you know of any class additions.[ ] All Block Devices
[ ] Filesystem's
Related: #6684
Pull request type
CC @geky @bridadan @dlfryar @0xc0170 @pan- @kjbracey-arm