警告:变量'{variable}'设置但未使用 - C ++

时间:2013-11-27 18:46:38

标签: c++

嗯,它抱怨说这些变量已被声明但未被使用。他们当然使用。可能是什么原因?

recorders/r5000/r5000.c: In function ‘r5000_locate_device’:
recorders/r5000/r5000.c:201:9: warning: variable ‘open_status’ set but not used [-Wunused-but-set-variable]
 int open_status = usb_set_configuration(device_handle,1);
     ^
recorders/r5000/r5000.c: In function ‘r5000_start_stream’:
recorders/r5000/r5000.c:258:7: warning: variable ‘bytes’ set but not used [-Wunused-but-set-variable]
int bytes;
   ^
recorders/r5000/r5000.c: In function ‘r5000_get_power_state’:
recorders/r5000/r5000.c:551:7: warning: variable ‘len’ set but not used [-Wunused-but-set-variable]
   int len;
   ^
recorders/r5000/r5k_sat.c: In function ‘sat_read_pmt_pkt’:
recorders/r5000/r5k_sat.c:120:17: warning: variable ‘last_sec’ set but not used [-Wunused-but-set-variable]
int sid, sec, last_sec, pcrpid, epid, type;
             ^
recorders/r5000/r5k_sat.c:120:12: warning: variable ‘sec’ set but not used [-Wunused-but-set-variable]
int sid, sec, last_sec, pcrpid, epid, type;

我试图在这里包含r5000.c,但论坛不会让我这么做。 ("代码太多")所以它在这里:https://pastee.org/mu3y9

1 个答案:

答案 0 :(得分:2)

仅查看open_status,警告是正确的:

  if (device_handle) {
    int open_status = usb_set_configuration(device_handle,1);

    open_status = usb_claim_interface(device_handle,0);

    open_status = usb_set_altinterface(device_handle,0);
  }

它只被分配给,而不是被使用。