I was going through AFNetworking
implementation and I found this
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wassign-enum"
[request setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]];
#pragma clang diagnostic pop
(AFHTTPClient:489-492)
The assign-enum
warning is obviously being turned off, but I wonder what does it mean.
What is the warning thrown by clang in that case?
The warning emitted in the absence of the clang pragmas is:
Integer constant not in range of enumerated type 'NSJSONWritingOptions' (aka 'enum NSJSONWritingOptions')
Looking at the declaration of NSJSONWritingOptions
, we see that there is no defined value for 0:
enum { NSJSONWritingPrettyPrinted = (1UL << 0) }; typedef NSUInteger NSJSONWritingOptions;
The docs do suggest passing 0, but there is no option defined like NSJSONWritingNoOption = 0
, and thus we are assigning a constant (0) to an enum type that doesn't define 0 as a possible value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With