warning: passing argument 1 of 'numberWithBool:' with different width due to prototype

只谈情不闲聊 提交于 2019-12-13 04:59:51

问题


The compiler complains about this, after I activated all kind of warnings:

I create an NSNumber like this:

NSNumber *num = [NSNumber numberWithBool:YES];

warning: passing argument 1 of 'numberWithBool:' with different width due to prototype

it complains about the value I provided. What's wrong with "YES"? What does that mean?


回答1:


It means that you have turned on one of the über-anal warnings about type coercion related to size changes. The compiler is complaining -- likely erroneously, from what I can tell -- that YES is being converted from one width to another -- from 8 bits to 32, most likely.

Turn off that particular warning. There are a number of compiler warnings that have grown to be effectively useless over the years.




回答2:


Try removing -Wconversion, or if that's not there, adding -Wno-conversion




回答3:


Remove -Wconversion

See man (1) gcc



来源:https://stackoverflow.com/questions/1372268/warning-passing-argument-1-of-numberwithbool-with-different-width-due-to-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!