错误:预期‘}’在输入结束时

发布于 2024-11-16 04:01:23 字数 1265 浏览 1 评论 0原文

我有以下代码:

#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 函数的右大括号,但显然情况并非如此,而且我看不出还有什么地方可能遗漏了任何括号。其他人能发现我在这里做错了什么吗?

I have the following code:

#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;
}

and the only thing preventing it from compiling is the error message specified in the title of this question. The problem line has been identified as the closing brace of the main function, but that obviously isn't the case, and I can't see where else I could have missed out any parentheses. Can anyone else spot what I'm doing wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

节枝 2024-11-23 04:01:24

如果出现此类错误,最好定位错误。您可以通过注释代码块来简单地做到这一点。

在此示例中,您可以注释主体 get_credentials 函数并检查会发生什么。

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

In case of such errors it is good idea to localize error. You can do it simply, by commenting blocks of code.

In this example you can comment body get_credentials function and check what will happen.

Also good idea to paste empty line at the end of source code file.

人心善变 2024-11-23 04:01:24

也许某些包含的标头的大括号不匹配。

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

尝试尽可能多地注释掉(尤其是所有包含的内容)以使其编译,然后将代码放回原处,直到找到问题所在。

Maybe some of the included headers has mismatched braces.

Maybe the compiler is bad at handling files with non-empty last line, and there is such line in some of the files.

Try commenting out as much as you can (especially all includes) to make it compile, and then putting code back in until you localize the problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文