Using the GCC __unused attribute with Objective-C

前端 未结 5 1520
野的像风
野的像风 2021-01-04 04:31

Is it possible to use the __unused attribute macro on Objective-C object method parameters? I\'ve tried placing it in various positions around the parameter declaration but

5条回答
  •  自闭症患者
    2021-01-04 05:13

    I can compile the following just fine:

    - (NSString *) test:(__unused NSString *)test {
        return nil;
    }
    

    Edit: Actually, that may not be strictly an arch thing:

    Phoenix-VI:CouchPusher louis$ cc -c Pusher.m -Wall -Werror
    Phoenix-VI:CouchPusher louis$ cc -c Pusher.m -Wall -Werror  -Wunused-parameter
    cc1obj: warnings being treated as errors
    Pusher.m:40: warning: unused parameter ‘test’
    Phoenix-VI:CouchPusher louis$ 
    

    So -Wall does not include not include -Wunused-parameter....

提交回复
热议问题