错误:输入末尾应为“}”

error: expected ‘}’ at end of input

本文关键字:输入 错误      更新时间:2023-10-16

我有以下代码:

#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函数的右大括号,但显然不是这样,而且我看不出还有什么地方可以漏掉括号。其他人能发现我在这里做错了什么吗?

如果出现此类错误,最好将错误本地化。您可以简单地通过注释代码块来实现这一点。

在本例中,您可以对主体get_credentials函数进行注释,并检查会发生什么。

在源代码文件的末尾粘贴空行也是个好主意。

可能包含的某些标头具有不匹配的大括号。

也许编译器不擅长处理最后一行不为空的文件,并且在某些文件中存在这样的行。

试着尽可能多地注释(尤其是所有包含)以使其编译,然后将代码放回原处,直到您将问题本地化。