简体   繁体   English

预期的 ; 在顶级声明符之后,xcode 中出现错误

[英]Expected ; after top level declarator, error in xcode

I am working with this utils.c file in xcode, which has the following:我正在 xcode 中使用这个utils.c文件,它具有以下内容:

 #if FF_API_AVCODEC_OPEN
    int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
    {
        return avcodec_open2(avctx, codec, NULL);
    }

It's causing an Expected ; after top level declarator它导致了Expected ; after top level declarator Expected ; after top level declarator , error (during build) in xcode at this line: int attribute_align_arg avcodec_open(.... Expected ; after top level declarator int attribute_align_arg avcodec_open(.... ,xcode 中的错误(在构建期间)在这一行: int attribute_align_arg avcodec_open(....

Why?为什么? and what should I do to resolve this.我该怎么做才能解决这个问题。

Thank you.谢谢你。

I ran into this error when using the auto completion.我在使用自动完成时遇到了这个错误。

When inserting the parameter of a function, XCode will insert placeholders that need to be edited but show as completely valid C++ in the GUI.当插入函数的参数时,XCode 将插入需要编辑但在 GUI 中显示为完全有效的 C++ 的占位符。

It took me some hours until I checked my file in another editor, revealing that instead of the expected:我花了几个小时,直到我在另一个编辑器中检查我的文件,发现而不是预期的:

void func(int a) void func(int a)

XCode had actually inserted XCode实际上已经插入

void func(<#int a#>) void func(<#int a#>)

In the XCode editor the parameter shows as int a with a light blue background, so it isn't easy to spot as the source of the compiler error.在 XCode 编辑器中,参数显示为带有浅蓝色背景的int a ,因此不容易将其视为编译器错误的来源。

I got a similar error in xcode for the following code:对于以下代码,我在 xcode 中遇到了类似的错误:

#ifndef Parser_hpp
#define Parser_hpp

#include <string>
std::string getTitle();

#endif /* Parser_hpp */

The reason was that the code had to be wrapped with C++ preprocessor directives.原因是代码必须用 C++ 预处理器指令包装。 Like so:像这样:

#ifndef Parser_hpp
#define Parser_hpp
#if defined __cplusplus

#include <string>
std::string getTitle();

#endif /* __cplusplus */
#endif /* Parser_hpp */

I ran into this after moving a class to a dynamic library but leaving the old import around.在将一个类移动到动态库但保留旧的导入后,我遇到了这个问题。 Commenting out the old import resolved the issue (but it wasn't the first thing I looked for as the dynamic library import was earlier and also showed an error).注释掉旧的导入解决了这个问题(但这不是我寻找的第一件事,因为动态库导入更早并且还显示了错误)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 顶级声明符错误但程序运行正常 - Top level declarator error but the program runs correctly 未知类型名称“类”; 你是说班级? CCApplicationProtocol.h,CCApplication.h和预期的&#39;;&#39;上的错误 在顶级声明器错误之后 - Unknown Type name 'class'; did you mean Class'? ERROR on CCApplicationProtocol.h, CCApplication.h and Expected ';' after top level declarator ERROR 错误:预期 function 声明符后的 function 正文 - error: expected function body after function declarator C ++-函数声明符后的预期函数体-Xcode 9.0 - C++ - Expected function body after function declarator - Xcode 9.0 嵌套类。 错误:预期参数声明符-用于内部类实例 - Nested Class. error: expected parameter declarator - for inner class instance 向量声明“预期参数声明符” - Vector declaration "expected parameter declarator" C ++:调用单例方法将导致“函数声明符后有预期的函数体” - C++: calling a singleton method results in “expected function body after function declarator” C ++模板类编译错误:在&#39;&lt;&#39;标记之前的预期init-declarator - C++ Template Class Compilation Error: expected init-declarator before '<' token Xcode中的预期表达错误 - Expected Expression Error in Xcode CMake顶级Xcode项目属性 - CMake Top Level Xcode Project Properties
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM