2013-02-23 44 views
-2

无法编译c程序,符号重定义问题。已经尝试了各种可变数据类型定义,对于浮点和静态浮点数都无法理解这里发生了什么。给了它一个好镜头,任何帮助表示赞赏。c静态浮动错误:'????'重新声明为不同种类的符号

克里斯

$ gcc -Wall -g -O6 -I../include -c -o edge.o edge.c

错误消息:

 
problem with edge.c: In function ‘qc_edge’: 
edge.c:30:15: error: ‘kernel’ redeclared as different kind of symbol 
edge.c:23:77: note: previous definition of ‘kernel’ was here 

代码片段加上行号:

18 //qc_edge (q, scan, start, gap, conv_kernel, 3, 3)); 
19 } 
20 
21 /******************************************************************/ 
22 
23 scanbuf *qc_edge (struct qcam *q, scanbuf *scan, int start, int gap, float *kernel, int 
kernel_x, int kernel_y) 
24 { scanbuf *scantmp; 
25 int i; 
26 int s, height, width, 
27 grad; 
28 float deltaX, deltaY; 
29 
30 static float kernel [3][3] = {{1, 2, 1}, 
32     {2, -1, 2}, 
33     {1, 2, 1}}; 

回答

1
scanbuf *qc_edge (struct qcam *q, scanbuf *scan, int start, int gap, float *kernel, int 
kernel_x, int kernel_y)            ^^^^^^^^^^^^// pointer to float type 

static float kernel [3][3] = {{1, 2, 1}, array of float. So you cant have one variable with two declaration in same scope. try changing the variable name. 

尝试:

24 { scanbuf *scantmp; 
25 int i; 
26 int s, height, width, 
27 grad; 
28 float deltaX, deltaY; 
29 
30 static float kernel_temp [3][3] = {{1, 2, 1}, <---- Change name 
32     {2, -1, 2}, 
33     {1, 2, 1}};