I just now learned about the __unused flag that can be used when compiling with GCC and the more I learn about it, the more questions I have...
Why does this compile without warning/error? It seems strange that I specifically tell the compiler I won't be using a variable, then when I use it, things proceed as normal.
- (void)viewDidLoad
{
[super viewDidLoad];
[self foo:0];
}
- (void)foo:(NSInteger)__unused myInt
{
myInt++;
NSLog(@"myInt: %d", myInt); // Logs '1'
}
Also, what is the difference between the following two method signatures?
- (void)foo:(NSInteger)__unused myInt;
- (void)foo:(NSInteger)myInt __unused;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…