Fix a defined() check

Close #3233