It sounds like you just need a new inner scope from which you can declare non-conflicting identifiers. This is why it's always a good idea to wrap your identifier-declaring macros in a single do-while block, or simply a block. For example, you can change your macro to accept a code block and still keep consecutive invocations from conflicting with each other:
#define CFICreateAnimationInScope(BLOCK) { \
CABasicAnimation* anim = [CABasicAnimation animation]; \
BLOCK \
} \
void f() {
CFICreateAnimationInScope({
anim.keyPath = @"position.x";
anim.toValue = @10;
});
CFICreateAnimationInScope({
anim.keyPath = @"position.y";
anim.toValue = @50;
});
}
Beyond that, there's actually using a function-like macro (you seem to be confusing macros and C functions from the looks of that pair of empty parens) combined with the scoping changes above to make little animation factories.