2013-03-14 119 views
0

此錯誤不斷顯示出來,每次我編譯我的程序:這個C編譯器錯誤是什麼意思?

ch.c: In function 'my_ch': 
ch.c:8:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' 
    token 
ch.c:20:1: error: expected '{' at end of input 

但是我想我有我的格式正確:

void my_ch() 
{ 
    /*some initialization stuff here*/ 

    while (/*conditions here*/) { 
     /*insert some code here*/ 
    } 

return; 
} 

我的8號線是void my_ch()一前一後和20是一個在return;之後。有沒有人有線索爲什麼錯誤不斷顯示?非常感謝

編輯

//ch 
#include <stdio.h> 
#include "ch.h" 
#define BUFLEN 2500 
#define MAC 3000 
<space> 

第七行是void my_ch()

+0

爲什麼多餘的回報? – Sinkingpoint 2013-03-14 03:37:16

+4

包含文件中的語法錯誤?這種錯誤通常是由於較早的語法錯誤。 – 2013-03-14 03:37:31

+2

你能告訴我們你在函數聲明之前有什麼嗎?粘貼在1-7行,是我的意思。我懷疑問題在那裏。 – angelatlarge 2013-03-14 03:38:28

回答

1

ch.h中有些東西未完成。也許像最後一個缺少分號的函數原型。什麼是ch.h?

+0

噢,謝謝。我知道了。 – Sakamoto 2013-03-14 04:05:52

1

ch.h可能有一個結構聲明中沒有 ';'結束'}'後。

+0

我沒有使用任何結構聲明 – Sakamoto 2013-03-14 03:54:41

+0

@Sakamoto然後你在ch.h中有一些其他的錯誤......我提到的那個只是一個很常見的錯誤。 – 2013-03-14 03:56:28