GitHub user klazuka opened a pull request: https://github.com/apache/thrift/pull/202
THRIFT-2676 Avoid 'i386' name collision in generated Cocoa/objc code [THRIFT-2676](https://issues.apache.org/jira/browse/THRIFT-2676) This fixes a bug in the cocoa code generator where the variable used by a for-loop can conflict with a built-in symbol when the temporary variable counter is equal to 386. The generated variable name, 'i386', conflicts with a macro built-in to the compiler. I can reproduce this bug on Xcode 5 as well as Xcode 6. It appears to only affect iOS projects, not OS X projects. My fix simply prefixes the generated variable with 'idx' instead of 'i'. This test code demonstrates the problem, regardless of Thrift codegen. ``` int i386 = 42; printf("foobar %d\n", i386); ``` Which results in the following compiler error: ``` /Users/keith/Desktop/ReservedSymbolTest/ReservedSymbolTest/ViewController.m:22:7: error: expected identifier or '(' int i386 = 42; ^ <built-in>:143:14: note: expanded from here ^ 1 error generated. ``` You can merge this pull request into a Git repository by running: $ git pull https://github.com/klazuka/thrift THRIFT-2676-cocoa-gen-name-collision Alternatively you can review and apply these changes as the patch at: https://github.com/apache/thrift/pull/202.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #202 ---- commit 4fc71285052ab04998d990a5de6b071ff53f3c47 Author: Keith Lazuka <klaz...@acompli.com> Date: 2014-08-25T22:31:49Z THRIFT-2676 Avoid 'i386' name collision in generated Cocoa/objc code This fixes a bug in the cocoa code generator where the variable used by a for-loop can conflict with a built-in symbol when the temporary variable counter is equal to 386. The generated variable name, 'i386', conflicts with a macro built-in to the compiler. I can reproduce this bug on Xcode 5 as well as Xcode 6. It appears to only affect iOS projects, not OS X projects. My fix simply prefixes the generated variable with 'idx' instead of 'i'. This test code demonstrates the problem, regardless of Thrift codegen. int i386 = 42; printf("foobar %d\n", i386); Which results in the following compiler error: /Users/keith/Desktop/ReservedSymbolTest/ReservedSymbolTest/ViewController.m:22:7: error: expected identifier or '(' int i386 = 99; ^ <built-in>:143:14: note: expanded from here ^ 1 error generated. ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---