编译选项引发的ERROR C2275:illegal use of this type as an expression

error C2275: 'CONTACT_e_MYFAVES_Return' : illegal use of this type as an expression

: see declaration of 'CONTACT_e_MYFAVES_Return'

why ? The declaration of  'CONTACT_e_MYFAVES_Return' is ok, had been validated.

So, what's wrong with you,'CONTACT_e_MYFAVES_Return'?

Jesun's answer:

 

     if  ( a_MyFavesId  <   0   ||  a_MyFavesId  >=  MYFAVES_COUNT  ||   ! a_pBirthday)
    
{
        
return CONTACT_MYFAVES_INVALID_PARAM;
    }


    CONTACT_e_MYFAVES_Return state;

    state 
=  CONTACT_MYFAVES_UNKNOWN_ERROR;

 

"    CONTACT_e_MYFAVES_Return state;" (declaration)must placed on the beginning of function, just like the followed:

 

    CONTACT_e_MYFAVES_Return state;

    
if  ( a_MyFavesId  <   0   ||  a_MyFavesId  >=  MYFAVES_COUNT  ||   ! a_pIconName  ||   ! a_pIconNameSize)
    
{
        
return CONTACT_MYFAVES_INVALID_PARAM;
    }


    state 
=  CONTACT_MYFAVES_UNKNOWN_ERROR;

In this case, the compile option is key. In VC default compile option, there no problem.

But when compile option is strict, this style of writting can not compile with success.

你可能感兴趣的:(C++)