2011-06-15 122 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

也许一些的包括头不匹配的括号。

也许编译器在处理与非空的最后一行文件坏了,存在的一些文件,例如线。

尝试尽可能多地发表评论(特别是包括所有内容),然后将代码重新放入,直到您将问题本地化。