当我清理,构建和运行我的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 } #endifand 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().
更多推荐
发布评论