gpt4 book ai didi

C++ 循环 : expected primary-expression before ‘;’ token

转载 作者:搜寻专家 更新时间:2023-10-31 00:00:36 25 4
gpt4 key购买 nike

<分区>

我有一个如下所示的循环,我认为问题出在标记为“参见此处”的内部 for 循环。这有什么问题吗?

// measure time to write different sizes of data
for (int i = 0; i < sizeof(sizes)/sizeof(int); i++) {
lengthMod = sizes[i]/sizeof(int) - 1;

start = wall_clock_time();

for (unsigned int j = 0; j < 10; j++) // << See here!!!
tmp = 1;

// force any write back cache to flush. read from other data source
for (unsigned int j = 0; j < REPS; j++) // << Or here!!!
tmp = j;

end = wall_clock_time();
timeTaken = ((float)(end - start))/1000000000;
fprintf(stderr, "%d, %1.2f \n", sizes[i]/1024, ((float)(end - start))/1000000000);
}

可以看到 full source on GitHub ~第 32 行


g++ -O3 cache-write.cpp -o cache-write -lrt
cache-write.cpp: In function ‘int main()’:
cache-write.cpp:36:27: error: expected primary-expression before ‘;’ token
cache-write.cpp:36:27: error: expected ‘)’ before ‘;’ token
cache-write.cpp:36:29: error: name lookup of ‘j’ changed for ISO ‘for’ scoping [-fpermissive]
cache-write.cpp:36:29: note: (if you use ‘-fpermissive’ G++ will accept your code)
cache-write.cpp:36:32: error: expected ‘;’ before ‘)’ token
cache-write.cpp:44:11: error: ‘data1’ was not declared in this scope
make: *** [cache-write] Error 1

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com