-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Pollution of global namespace due to using namespace EspSoftwareSerial; #9055
Comments
Also see plerup/espsoftwareserial#301 edit: nvm the code snippet, enum does not work like that (sadly) |
Can't use 3.1.2 release because it should oblige to change all existing applications. |
The problem comes from the directive: " using namespace EspSoftwareSerial; " line 433 which is not a good pratice in terms of programming because it may lead to collision problem. Please have a look at this page https://learn.microsoft.com/en-us/cpp/cpp/namespaces-cpp?view=msvc-170 and pay a special attention to the note in chapter "Using directives" |
What I mean, the fix should happen upstream first. Please re-read the issue I linked, swserial is an external lib :> |
You just linked back to this issue and nothing else. |
EspSoftwareSerial is external library, so @mcspr tries to say that you are barking on wrong tree here - please report the error in the original one, because the original repository has to be changed first (it's used as submodule). |
Where is the original repository ? |
Did you try to click https://github.com/esp8266/Arduino/tree/master/libraries at the library? It leads to https://github.com/plerup/espsoftwareserial/tree/bcfd6d10e6a45a0d07705d08728f293defe9cc1d ... |
The problem comes because of the directive using namespace EspSoftwareSerial wich leads to a global pollution. |
Yes, exactly described here plerup/espsoftwareserial#301 as @mcspr told you... This is wrong repository as it has nothing to do with the issue. |
In version 3.1.1 of SoftwareSerial.h we have:
enum SoftwareSerialConfig {
SWSERIAL_5N1 = SWSERIAL_PARITY_NONE,
etc...
this was changed in version 3.1.2 with:
enum Config {
SWSERIAL_5N1 = SWSERIAL_PARITY_NONE,
etc...
which lead to a conflicting name problem when Config is used in an application program but with another definition despite the namespace statement added in SoftwareSerial.h version 3.1.2
The text was updated successfully, but these errors were encountered: