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

error: prototype for '...' does not match any in class '...' #2

Open
ste2425 opened this issue May 13, 2022 · 2 comments
Open

error: prototype for '...' does not match any in class '...' #2

ste2425 opened this issue May 13, 2022 · 2 comments

Comments

@ste2425
Copy link

ste2425 commented May 13, 2022

After making the changes defined in #1 and trying to recompile i get the following error:

Arduino\libraries\MCP4251\src\MCP4251.cpp:64:6: error: prototype for 'void MCP4251::DigitalPotSetWiperPosition(bool, unsigned int)' does not match any in class 'MCP4251'
 void MCP4251::DigitalPotSetWiperPosition(bool potNum, unsigned int value)
      ^~~~~~~
In file included from Arduino\libraries\MCP4251\src\MCP4251.cpp:1:0:
Arduino\libraries\MCP4251\src\MCP4251.h:43:8: error: candidate is: void MCP4251::DigitalPotSetWiperPosition(bool, uint16_t)
   void DigitalPotSetWiperPosition(bool potNum, uint16_t value); // Need confirmation if it is working
        ^~~~~~~~~~~~~~~~~~~~~~~~~~
exit status 1
Error compiling for board Arduino NANO 33 IoT.

To fix it i modified line 43 in MCP4251.h from:

void DigitalPotSetWiperPosition(bool potNum, uint16_t value); // Need confirmation if it is working

to

void DigitalPotSetWiperPosition(bool potNum, unsigned int value); // Need confirmation if it is working

With that change it now compiles. I'm unable to test if it actually works just yet but figured i would report this.

This is using Arduino IDE version: 1.8.16 and targeting an Arduino Nano 33 IOT.

I will report back about it physically working or not once ive got everything hooked up.

@ste2425
Copy link
Author

ste2425 commented May 13, 2022

Just want to add this is a super cool Lib that will save me a ton of time. I'll be using in my PSP project here: https://github.com/ste2425/PSP-Bluetooth-Controller

Thanks for making it 👍

@kulbhushanchand
Copy link
Owner

Thank you for reporting the issue and suggesting appropriate changes.
and also for your kind appreciation to my work. I'm glad you are finding it useful...

Regarding the error, I think the issue arises because I have used unsigned int at

void MCP4251::DigitalPotSetWiperPosition(bool potNum, unsigned int value)

Using unsigned int makes code machine/compiler dependent, because of the bits allocated to int varies as per the micro controller (e.g. arduino uno vs due). Therefore, uint16_t is preferred, which always allocate same number of bits irrespective of the machine.

Your solution is also correct 👍

However, can you also test another future-proof solution by not making any change in MCP4251.h and instead replacing unsigned int by uint16_t in the MCP4251.cpp at

void MCP4251::DigitalPotSetWiperPosition(bool potNum, unsigned int value)

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

No branches or pull requests

2 participants