digitalReadFast() not working on Mega [Solved]

Yet another option is to treat 'selectVal' as a bool:

if (selectVal) {

That would be my preferred style as well.
Note that digitalRead() is supposed to return a "PinStatus" enum these days, which is distinctly NOT a boolean. Which is unfortunate, IMO. :frowning:

The correct patch is probably like:

#define __digitalReadFast(P ) \
   :
( BIT_READ(*__digitalPinToPINReg(P), __digitalPinToBit(P))) ? HIGH : LOW )