//正式服務器#define API_DOMAIN @"www.online.com"http://測試服務器//#define DOMAINXX @"192.168.0.10"#define API_SYSTEM @"http://"API_DOMAIN@"/system/"#define API_USER @"http://"API_DOMAIN@"/user/"API_SYSTEM 宏展開后是: @"http://"@"www.online.com"@"/system/"編譯器會自動將字符中連接起來,目的實現(xiàn)。c語言下的實現(xiàn)://正式服務器#define API_DOMAIN "www.online.com"http://測試服務器//#define DOMAINXX "192.168.0.10"#define API_SYSTEM "http://"API_DOMAIN"/system/"
#define API_USER "http://"API_DOMAIN"/user/"
參考:http://stackoverflow.com/questions/8844981/how-to-expand-a-macro-into-nsstring-without-using-any-string-concatenation-at-ru
http://stackoverflow.com/questions/798221/c-macros-to-create-strings
最后,感謝萬能的google,萬能的stackoverflow。
新聞熱點
疑難解答