Token pasting/concatenation question
Wed Apr 22 17:43:00 GMT 2009
I would probably just do this:
#define API_URL(tail) "http://localhost:2000/api/" #tail
#define URL_GET_USER_DATA API_URL(/get/user/data.json)
On Wed, Apr 22, 2009 at 10:16 AM, Jon Drukman <firstname.lastname@example.org> wrote:
> I want to do the following:
> #define API_URL(tail) @"http://localhost:2000/api/##tail"
> #define URL_GET_USER_DATA API_URL(/get/user/data.json)
> and then when I refer to URL_GET_USER_DATA later in the code, it should
> expand to @"http://localhost:2000/api/get/user/data.json"
> I can not get "tail" to expand in the API_URL macro. I've tried every
> combination of single and double pound signs. (Well, every combination
> except for whatever the correct one is, obviously.)
> gcc 4.0.1 on mac os X, trying to build an iPhone app in Objective-C.
> Thanks for any help.
More information about the Gcc-help