1 c++ compiler-errors syntax-error
我有以下代码:
#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;
}
Run Code Online (Sandbox Code Playgroud)
并且阻止它编译的唯一因素是在这个问题的标题中指定的错误消息.问题行已被确定为main
函数的结束括号,但显然情况并非如此,我无法看到我可能错过任何括号的其他地方.谁能在这里发现我做错了什么?
如果出现此类错误,最好将错误本地化.你可以通过注释代码块来简单地完成它.
在这个例子中,你可以评论身体get_credentials
功能并检查会发生什么.
在源代码文件的末尾粘贴空行也是个好主意.
也许其中一些标头的花括号不匹配。
也许编译器在处理最后一行非空的文件时很不好,并且某些文件中有这样的行。
尝试尽可能多地注释掉(尤其是所有包含的注释)以使其编译,然后再放回代码,直到将问题本地化为止。