2011-06-15 125 views
1

末我有以下代碼:錯誤:預期「}」在輸入

#include <libubuntuone-1.0/u1-music-store.h> 
#include <libsyncdaemon-1.0/libsyncdaemon/syncdaemon-authentication.h> 
#include <libsyncdaemon-1.0/libsyncdaemon/syncdaemon-credentials.h> 
#include <libsyncdaemon-1.0/libsyncdaemon/syncdaemon-daemon.h> 

static void 
get_credentials (U1MusicStore *music_store, 
           gchar **oauth_consumer_token, 
           gchar **oauth_consumer_secret, 
           gchar **oauth_token, 
           gchar **oauth_token_secret) 
{ 
    SyncdaemonCredentials *credentials; 
    *oauth_consumer_token = *oauth_consumer_secret = *oauth_token = *oauth_token_secret = NULL; 

    *oauth_consumer_token = g_strdup (syncdaemon_credentials_get_consumer_key (credentials)); 
    *oauth_consumer_secret = g_strdup (syncdaemon_credentials_get_consumer_secret (credentials)); 
    *oauth_token = g_strdup (syncdaemon_credentials_get_token (credentials)); 
    *oauth_consumer_secret = g_strdup (syncdaemon_credentials_get_token_secret (credentials)); 
} 

int main() 
{ 
    return 0; 
} 

和唯一阻止它編譯在這個問題的標題指定的錯誤消息。問題行已被確定爲main函數的大括號,但顯然不是這種情況,並且我看不到其他任何括號。任何人都可以發現我在這裏做錯了嗎?

+4

我沒有看過所有上面的代碼,但也請檢查您的頭文件。你確定他們都好嗎? – 2011-06-15 22:00:36

+0

如果您註釋掉'get_credentials()'的主體,它會編譯嗎?實際上更進一步,註釋掉除#include頭之外的所有內容。這些頭文件應該自行編譯,否則可能會在某處出現「{」字符。 – greatwolf 2011-06-15 22:00:46

+0

你能發佈整個錯誤嗎? – Suroot 2011-06-15 22:01:46

回答

5

在這種錯誤的情況下,它是好主意,定位錯誤。您可以簡單地通過評論代碼塊來完成。

在這個例子中,你可以發表評論身體get_credentials功能和檢查會發生什麼。

而且好主意,粘貼空行的源代碼文件的末尾。

4

也許一些的包括頭不匹配的括號。

也許編譯器在處理與非空的最後一行文件壞了,存在的一些文件,例如線。

嘗試儘可能多地發表評論(特別是包括所有內容),然後將代碼重新放入,直到您將問題本地化。