This happens because the BM_LEG_MODEL is defined later than the if-clause. #define statements are pre-processor commands that effectively replace pieces of code with specified values. The order matters.
It could be that you need to define BM_LEG_MODEL explicitly before using this statement or before including the file that has this statement.