ios – 使用函数指针声明编译错误

我试图将openssl导入到我的 swift项目中,但是当我在xxx-Bridging-Header.h中添加了#import“ras.h”时,我在下面得到了编译错误.
<unkNown>:0: error: /Users/wenyun/workspace/newsvn/newios/ios/VanJoyPay2/VanJoyPay2/opensource/OpenSSlrsAWrapper/openssl/include/openssl/rsa.h:100: expected ')'
<unkNown>:0: note: /Users/wenyun/workspace/newsvn/newios/ios/VanJoyPay2/VanJoyPay2/opensource/OpenSSlrsAWrapper/o penssl/include/openssl/rsa.h:100: to match this '('

ras.h:100是:

int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */

我通过将const BIGNUM * I重命名为const BIGNUM * i来修复错误.有人知道我为什么这么特别的角色?

我今天做了另一个测试,结果看起来很奇怪.
我创建了一个新的swift项目,写了3个头文件

test.h
int test(char *I);

test2.h
#import "test3.h"
#import <Foundation/Foundation.h>

test3.h
int test3();


xxx-Bridging-Header.h
#import "test2.h"
#import "test.h"

我再次收到编译错误

最后,删除“#import”使一切都可以.

Why the character "I" Could not work together with #import <xxx>?

解决方法

问题不在于Swift.它是由/usr/include/complex.h文件中的I的以前定义引起的(如 Brian Chen所猜测的).

以下是编译器报告的违规行:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhonesimulator.platform/Developer/SDKs/iPhonesimulator8.1.sdk/usr/include/complex.h:42:11: note: expanded from macro 'I'
#define I _Complex_I

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...