2013-02-23 135 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}};