【发布时间】:2015-12-19 10:00:41
【问题描述】:
我正在调试我的程序,但在 VS2010 中 cnt 的定义没有任何问题(相同的代码)。在 VS2013 中,cnt 是“未定义的”,这将导致程序出现故障。知道为什么吗?
int
adin_file_read(SP16 *buf, int sampnum)
{
FILE *fp;
int cnt = 0; //nº de bytes lido numa evocação da função adin_file_read
fp = gfp;
//sum_samples --> nº total de bytes lidos
//global_size --> nº total de bytes do buffer de audio
//Se é um ficheiro wav
if (wav_p) {
cnt = fread(buf, sizeof(SP16), sampnum, fp);
if (cnt == 0) {
if (feof(fp)) return -1; /* EOF */
if (ferror(fp)) {
jlog("Error: adin_file: an error occured while reading file\n");
adin_file_close();
return -2; /* error */
}
}
if (nowlen + cnt > maxlen) {
cnt = maxlen - nowlen;
}
nowlen += cnt;
}
else { //Se é um RAW FILE
//AXY5
if (has_pre) {
int i;
has_pre = FALSE;
for (i = 0; i <= sampnum; i++){
if (i > global_size / sizeof(SP16)) {
cnt = i;
sum_samples = i;
break;
}
buf[i] = real_data[i];
}
if (cnt == 0) {
if (sum_samples > global_size / sizeof(SP16)){
return -1;
}
} (.....continue).. return cnt;
【问题讨论】:
-
你应该对截图感到抱歉。请将代码作为文本复制并粘贴到问题中。
-
在哪里你得到错误?
-
目的是展示视觉工作室的行为。 @MOehm 很抱歉
-
我没有错误,但是因为
cnt显然没有定义,所以最终的结果不会是正确的。 -
啊,调试器出错,调试器找不到变量。如果变量由于某种原因已被优化掉,通常会出现这种情况。尝试禁用所有优化并重试。
标签: c visual-studio visual-studio-2013