XCode使用未声明的标识符,仅在文件打开时出现(XCode use of undeclared identifier, only appears if the file is opened)

编程入门 行业动态 更新时间:2024-10-27 10:29:32
XCode使用未声明的标识符,仅在文件打开时出现(XCode use of undeclared identifier, only appears if the file is opened)

当我清理,构建和运行我的XCode项目一切顺利,但如果我打开一个调用该函数的文件,则会出现使用未声明的标识符'func()'。 这是整个实施:

该函数被称为:

func();

'func()'在.h文件中被删除,如下所示:

#if __cplusplus extern "C" { #endif extern void func(); #if __cplusplus } #endif

和func()实现的是一个cplusplus库。

如果文件打开,为什么只出现错误,但是如果我不打开它,它运行并且工作得很好?

When I clean, build and run my XCode project all goes well, but if I open a file that calls the function, an Use of undeclared identifier 'func()' appears. This is the whole implementation:

The function is called:

func();

And 'func()' is decleared in a .h file like so:

#if __cplusplus extern "C" { #endif extern void func(); #if __cplusplus } #endif

and func() is implemented is a cplusplus library.

Why would the error ONLY appears if the file is open, but if I don't open it, it runs and works just fine?

最满意答案

Xcode有两种生成错误消息的方法。 通常这两个都会生成相同的消息,因此您不会检测到有两个系统。

第一个系统是编辑器,它执行语法着色和自动完成。 写错误后,它几乎会立即显示错误消息。

第二个系统是构建日志中显示的错误。

我怀疑你的项目有一个复杂的包含设置。 这可以防止第一个系统找到要包含的正确文件,因此无法找到func()的定义。

Xcode has two ways of generating error messages. Usually both of these generate the same messages, so you do not detect that there are two systems.

The first system is the editor which does syntax coloring and auto-completion. It will also show error messages almost instantly after you write an error.

The second system is errors shown in the build log.

I suspect that your project has a complicated include setting. This prevents the first system from finding the correct file to include and therefore it cannot find the definition of func().

更多推荐

本文发布于:2023-07-06 07:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047539.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标识符   声明   文件   XCode   undeclared

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!