Should useless type qualifiers on return types be used, for clarity?

后端 未结 6 1205
有刺的猬
有刺的猬 2020-11-30 09:05

Our static analysis tool complains about a \"useless type qualifier on return type\" when we have prototypes in header files such as:

const int foo();
         


        
6条回答
  •  一整个雨季
    2020-11-30 09:43

    You can use a different technique to illustrate your intent without making the tools unhappy.

    #define CONST_RETURN
    
    CONST_RETURN int foo();
    

    You don't have a problem with const char * because that's declaring a pointer to constant chars, not a constant pointer.

提交回复
热议问题