Page 1 of 1

ambiguous error with Pins

Posted: Tue Feb 04, 2020 6:52 am
by SeeCwriter
Using a NANO with v2.9.2.
Why do I get error "conversion from 'PinIO' to 'WORD' is ambiguous" for each of the following:

Code: Select all

WORD val = Pins[23];
WORD val = (WORD) Pins[23];
WORD val = ( Pins[23] ) ? 1:0;
But no error with:

Code: Select all

int  val = Pins[23];
BYTE val = Pins[23];
if ( Pins[23] ) 
  iprintf( "The pin is low" );

Re: ambiguous error with Pins

Posted: Tue Feb 04, 2020 7:47 am
by sulliwk06
I would be surprised if the "WORD val = ( Pins[23] ) ? 1:0;" didn't work. I think the PinIO class just only implements the conversion operators for int, BYTE, and bool. That 3rd example should be using the bool conversion and assigning 1 or 0 to your WORD, does it give that same conversion error?

I would either just add the WORD operator to the PinIO class or go with "WORD val = (bool) Pins[23];"