【问题标题】:Static library compile problems using Xcode 3.2.3使用 Xcode 3.2.3 的静态库编译问题
【发布时间】:2010-08-26 18:33:04
【问题描述】:

我正在尝试使用 Xcode 3.2.3 开发一个新的静态库。

Xcode 在我的 G.h 文件中给出了如下所示的奇怪错误消息。 这些错误的原因是什么?

查尔斯

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKitDefines.h>

@interface G : NSObject {
  int fontSize, canvasWidth, canvasHeight;
}

UIColor *lightslategray;  
  error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token

@property int fontSize, canvasWidth, canvasHeight;

-(void) DrawLine:(float)x1 :(float)y1 :(float)x2 :(float)y2 :(float) lineWidth: (UIColor *)color;
  error: expected ')' before 'UIColor'

@end

【问题讨论】:

    标签: xcode xcode3.2


    【解决方案1】:

    您的代码应该如下所示:

    #import <UIKit/UIKit.h>
    
    @interface G : NSObject {
      int fontSize, canvasWidth, canvasHeight;
      UIColor *lightslategray;  
    }
    
    @property (nonatomic, assign) int fontSize;
    @property (nonatomic, assign) int canvasWidth;
    @property (nonatomic, assign) int canvasHeight;
    
    -(void) drawLine: (float)x1 y1:(float)y1 x2:(float)x2 y2:(float)y2 lineWidth:(float) lineWidth color: (UIColor *)color;
    
    @end
    

    这是你的第一个 Objective C 程序,不是吗?

    【讨论】:

    • 是的,我是 Objective-c 开发的新手。但是,您的代码给出了相同的错误消息。当它是应用程序的一部分时,我的原始代码编译并运行良好。仅当我尝试将此代码移动到静态库项目时才会发生错误。肯定有其他问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-08
    相关资源
    最近更新 更多