GDB报告"在目前情况下&QUOT没有符号;在数组初始化 [英] GDB reports "no symbol in current context" upon array initialization
问题描述
我试图来初始化大小CEIL数组(buflen / 125.0)如下:
I am attempting to initialize an array with a size of ceil(buflen/125.0) as follows:
long long maxjpg = ceil(buflen/125.0);
long long arr[maxjpg];
我没有收到一个编译器错误,但GDB报告,在目前情况下没有符号'改编'。我发现的唯一的解决方法是通过硬编码数值到数组的大小,像这样:
I do not receive a compiler error, but GDB reports "no symbol 'arr' in current context". The only fix I have found is by hardcoding a numerical value into the array size like so:
long long arr[5];
我曾尝试铸造,采用不同的变量类型,使用常量
和这些方法的任意组合。我知道,CEIL返回双击
,我曾尝试与工作压力太大。
I have tried casting, using different variable types, using const
and any combination of these approaches. I know that ceil returns a double
, I have tried working with that too.
初始化值,并打印出来,像这样工作的:
Initializing a value and printing it like so works:
arr[0] = 25;
printf(pos 0 is %d\n", arr[0]);
输出: 0 POS机为25
印刷改编[0]
通过GDB后,该修改的结果的价值已经被优化掉了。
Printing arr[0]
through GDB after that modification results in "value has been optimized out".
最低可行code复制:
Minimum viable code to reproduce:
#include <math.h>
int main(void){
long long size = ceil(123.45);
long long arr[size];
return 0;
}
GDB的Fedora 7.4.50.20120120-52.fc17
GDB Fedora 7.4.50.20120120-52.fc17
推荐答案
沃拉斯目前没有广发行工作。有一个关于它打开一个bug,一个正在进行的项目来解决它: https://sourceware.org/gdb/wiki / VariableLengthArray
VLAs do not currently work in gdb. There's a bug open about it and an ongoing project to fix it: https://sourceware.org/gdb/wiki/VariableLengthArray
有在archer.git,在某些情况下工作的实现,但它不被视为不够好后备箱中去。
There's an implementation in archer.git that works in some cases, but it isn't considered good enough to go in trunk.
这篇关于GDB报告&QUOT;在目前情况下&QUOT没有符号;在数组初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!