我正在使用以下函数维护一些丑陋的遗留代码,我得到了
warning: value computed is not used
对于以下注释标记的行:
void ReadKeyValuePipe(char* buffer, char* key, char* value) {
char* pos;
char key_str[1024];
char* val = value;
sprintf(key_str,"%s:",key);
if((pos = strstr(buffer,key))) {
pos += strlen(key_str);
while (*pos && *pos != '|') {
*val = *pos;
*val++; // this is actually used
*pos++; // so is this
}
*val = 0;
}
}
当我删除这些行时,代码会中断。这是有道理的,因为它们似乎是递增的标记。
我如何让编译器识别出这些计算是实际使用的?