objective-c之预定义

//
//  main.m
//  预定义
//
//  Created by wu jianhua on 16-8-3.
//  Copyright (c) 2016年 wujianhua. All rights reserved.
//

#import <Foundation/Foundation.h>

#define  message_for(a, b) NSLog(@#a " and " #b ": We love you!")

#define tokenpaster(n) NSLog (@"token" #n " = %d", token##n)


#if !defined (MESSAGE)
#define MESSAGE "You wish!"
#endif

//参数化宏
#define MAX(x,y) ((x) > (y) ? (x) : (y))

typedef unsigned char BYTE;
#define TRUE  1
#define FALSE 0


#define DEBUG 0

#if DEBUG == 0
#define DebugLog(...)
#elif DEBUG == 1
#define DebugLog(...) NSLog(__VA_ARGS__)
#endif


//http://www.yiibai.com/objective_c/objective_c_preprocessors.html
int main(int argc, const char * argv[])
{

    
    
    NSLog(@"File :%s ", __FILE__ );
    NSLog(@"Date :%s ", __DATE__ );
    NSLog(@"Time :%s ", __TIME__ );
    NSLog(@"Line :%d ", __LINE__ );
    NSLog(@"ANSI :%d ", __STDC__ );
    
    message_for(Carole, Debra);
    
    int token110=1024;
    
    tokenpaster(110);
    
    NSLog(@"Here is the message: %s", MESSAGE);
    
    NSLog( @"Value of TRUE : %d", TRUE);
    NSLog( @"Value of FALSE : %d ", FALSE);
    
    DebugLog(@"Debug log, our custom addition gets printed during debug only" );
    
    NSLog(@"NSLog gets printed always" );
    
    //类型转换
    int sum = 17, count = 5;
    CGFloat mean;
    
    mean = (CGFloat) sum / count;
    NSLog(@"Value of mean : %f", mean );
          
                                  
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值