问题描述
Xcode build 打印此错误.
Xcode build prints this error .
未定义符号:
"EGViewportDimensionMake(unsigned int,无符号整数、无符号整数、无符号int)",引用自:- [Renderer render] in Renderer.o ld: 未找到符号 collect2: ld返回 1 个退出状态
我无法弄清楚是什么问题.我不擅长经典的 C 语法.这些是函数源代码文件:
I cannot figure out what's the problem. I'm not good at classic C syntax.These are the function source code files:
EGViewportDimension.h
#import <Foundation/Foundation.h>
struct EGViewportDimension
{
NSUInteger x;
NSUInteger y;
NSUInteger width;
NSUInteger height;
};
typedef struct EGViewportDimension EGViewportDimension;
EGViewportDimension EGViewportDimensionMake(NSUInteger x, NSUInteger y, NSUInteger width, NSUInteger height);
EGViewportDimension.m
#import "EGViewportDimension.h"
EGViewportDimension EGViewportDimensionMake(NSUInteger x, NSUInteger y, NSUInteger width, NSUInteger height)
{
EGViewportDimension dim;
dim.x = x;
dim.y = y;
dim.width = width;
dim.height = height;
return dim;
}
我引用并使用了这个:
渲染器.mm
#import "EGViewportDimension.h"
//.... many codes omitted.
EGViewportDimension vdim = EGViewportDimensionMake(0, 0, backingWidth, backingHeight);
推荐答案
我通过将 Renderer.mm 重命名为 Renderer.m 解决了这个问题.它使用了一些 C++ 类,所以我把它作为 Objective-C++ 代码,但是有一些问题.我删除了所有 C++ 调用并将其重命名为 Objective-C 代码.
I solved it by renaming Renderer.mm to Renderer.m.It was used some C++ classes so I made it as Objective-C++ code, but there was some problem.I removed all C++ calls and renamed it to Objective-C code.
但我仍然不知道使用经典 C 函数定义的 Objective-C++ 有什么问题.
But I still don't know what's the problem with Objective-C++ with classic C function definition.
----(编辑)----
----(edit)----
我把这个当成了另一个问题,我得到了答案.看这里:是否禁止调用经典C来自 Objective-C++ 类方法体的函数?
I asked this as another question, and I got an answer. See here:Does it prohibited calling classic C function from Objective-C++ class method body?
这篇关于我在 Objective-C 方法体中使用的 C 函数找不到 Xcode 打印符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!