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
Update JC_Button.h #14
Conversation
Simple changes to prevent gcc compiler warnings
Hello @tysonlt! Thanks for the note, glad you like the library. |
Had a closer look at this. Yes the scope doesn't belong on line 23 of the .h file so I will make that change. It is odd that I don't see any compiler warnings. But I do not understand the other change, just moving the definition of |
Hi Jack, here is the warning I get:
In file included from sketch/Typhoon.h:6:0,
from /Users/tll/Documents/Arduino/Typhoon/Typhoon.ino:6:
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:23:9:
warning: extra qualification 'Button::' on member 'Button' [-fpermissive]
Button::Button(uint8_t pin, uint32_t dbTime=25, uint8_t
puEnable=true, uint8_t invert=true)
^
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h: In
constructor 'Button::Button(uint8_t, uint32_t, uint8_t, uint8_t)':
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:69:18:
warning: 'Button::m_dbTime' will be initialized after [-Wreorder]
uint32_t m_dbTime; // debounce time (ms)
^
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:64:14:
warning: 'bool Button::m_puEnable' [-Wreorder]
bool m_puEnable; // internal pullup resistor enabled
^
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:23:9:
warning: when initialized here [-Wreorder]
Button::Button(uint8_t pin, uint32_t dbTime=25, uint8_t
puEnable=true, uint8_t invert=true)
^
In file included from
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.cpp:6:0:
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:23:9:
warning: extra qualification 'Button::' on member 'Button' [-fpermissive]
Button::Button(uint8_t pin, uint32_t dbTime=25, uint8_t
puEnable=true, uint8_t invert=true)
^
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h: In
constructor 'Button::Button(uint8_t, uint32_t, uint8_t, uint8_t)':
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:69:18:
warning: 'Button::m_dbTime' will be initialized after [-Wreorder]
uint32_t m_dbTime; // debounce time (ms)
^
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:64:14:
warning: 'bool Button::m_puEnable' [-Wreorder]
bool m_puEnable; // internal pullup resistor enabled
^
/Users/tll/Documents/Arduino/libraries/JC_Button-master/src/JC_Button.h:23:9:
warning: when initialized here [-Wreorder]
Button::Button(uint8_t pin, uint32_t dbTime=25, uint8_t
puEnable=true, uint8_t invert=true)
It doesn't like the variables being initialised in a different order than
what they were defined. I found an explanation here:
https://stackoverflow.com/questions/30364585/will-be-initialized-after-wreorder
It seems like the compiler is being very pedantic, but as a Java programmer
I have decided to run Arduino IDE with all warnings - it has saved me a
number of times. However I like listing my vars in order of type as well -
it looks neater :)
…On 14 May 2018 at 03:28, Jack Christensen ***@***.***> wrote:
Had a closer look at this. Yes the scope doesn't belong on line 23 of the
.h file so I will make that change. It is odd that I don't see any compiler
warnings.
But I do not understand the other change, just moving the definition of
m_time up a few lines. Surely that cannot make a difference. Am I missing
something?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFUtyyhjwb9bQmZl0crAfICKgQErmzPdks5tyG0ugaJpZM4T8waj>
.
--
Regards,
Tyson Lloyd Thwaites
|
My bad -- now that I have warnings turned up a bit, I see the same messages too! learncpp.com is a site I like. Initializer order is mentioned on this page: Initializer list order Perhaps surprisingly, variables in the initializer list are not initialized in the order that they are specified in the initializer list. Instead, they are initialized in the order in which they are declared in the class. For best results, the following recommendations should be observed:
|
PS: In the pull request, the m_time variable is moved but it should have been m_dbTime. |
Hello JC!
Thank you for this wonderful library. I found it after struggling with another library, and this does exactly what I need.
I had to make the following changes to prevent compiler warnings. No actual functionality has been changed.