Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // SW+Variadic.h
- // Sophtwhere
- //
- // Created by Jonathan Annett on 17/12/11.
- // Copyright (c) 2011 Sophtwhere. All rights reserved.
- //
- /*
- . This header contains macros that are core to the
- . Sophtwhere Objective C extension approach.
- .
- . They are used for counting macro arguments and automatic selection of
- . sub macros based on the number of arguments being used.
- .
- . Original source: these macros were adapated from information gleaned from
- . the following web posts, with the second url being the most likely candidate
- . as the original author.
- http://stackoverflow.com/questions/5365440/variadic-macro-trick
- http://cplusplus.co.il/2010/07/17/variadic-macro-to-count-number-of-arguments/
- */
- #define VA_NARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, N, ...) N
- #define VA_NARGS(...) VA_NARGS_IMPL(X,##__VA_ARGS__, 11, 10,9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
- #define VARARG_IMPL2(base, count, ...) base##count(__VA_ARGS__)
- #define VARARG_IMPL(base, count, ...) VARARG_IMPL2(base, count, __VA_ARGS__)
- #define VARARG(base, ...) VARARG_IMPL(base, VA_NARGS(__VA_ARGS__), __VA_ARGS__)
- #define __variadicName(...) VARARG(__variadicName_, __VA_ARGS__)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement