草庐IT

Declaration

全部标签

ios - Xcode 9 中的 "This function declaration is not a prototype"警告

使用Xcode9时,有一些编译器警告说Thisfunctiondeclarationisnotanprototype。它建议将void添加到方法体中,这将解决它。我遇到的问题是,这些警告也会针对系统API引发,例如UIApplication委托(delegate)方法:-(void)application:(UIApplication*)applicationhandleActionWithIdentifier:(NSString*)identifierforRemoteNotification:(NSDictionary*)userInfowithResponseInfo:(NSDi

c++ - 将char数组初始化为字符串值,未初始化的索引是否设置为null?

如果我有以下情况:chartest[10]="#";test[1]到test[9]是否保证为\0?还是只有test[1]保证为\0? 最佳答案 这个定义chartest[10]="#";等价于chartest[10]={'#','\0'};即数组的两个元素由初始化器显式初始化。数组的所有其他元素将被初始化为零,这意味着它们将被隐式设置为'\0'根据C++标准(第8.5.2节字符数组)3Iftherearefewerinitializersthantherearearrayelements,eachelementnotexplicit

c++ - 将char数组初始化为字符串值,未初始化的索引是否设置为null?

如果我有以下情况:chartest[10]="#";test[1]到test[9]是否保证为\0?还是只有test[1]保证为\0? 最佳答案 这个定义chartest[10]="#";等价于chartest[10]={'#','\0'};即数组的两个元素由初始化器显式初始化。数组的所有其他元素将被初始化为零,这意味着它们将被隐式设置为'\0'根据C++标准(第8.5.2节字符数组)3Iftherearefewerinitializersthantherearearrayelements,eachelementnotexplicit

c++ - 诠释 x;整数y;诠释*ptr;不是初始化吧?

我正在阅读J.P.Mueller和J.Cogswell的“C++All-in-OneforDummies”,偶然发现:#includeusingnamespacestd;intmain(){intExpensiveComputer;intCheapComputer;int*ptrToComp;...Thiscodestartsoutbyinitializingallthegoodiesinvolved—twointegersandapointertoaninteger.确认一下,这是一个错误,应该读作“...通过声明”,对吗?让我感到奇怪的是,这些基本错误仍然会出现在书籍中。

c++ - 诠释 x;整数y;诠释*ptr;不是初始化吧?

我正在阅读J.P.Mueller和J.Cogswell的“C++All-in-OneforDummies”,偶然发现:#includeusingnamespacestd;intmain(){intExpensiveComputer;intCheapComputer;int*ptrToComp;...Thiscodestartsoutbyinitializingallthegoodiesinvolved—twointegersandapointertoaninteger.确认一下,这是一个错误,应该读作“...通过声明”,对吗?让我感到奇怪的是,这些基本错误仍然会出现在书籍中。

c++ - g++ 拒绝,clang++ 接受 : foo(x) ("bar") ("baz");

有人拥有asked前几天为什么有些东西用clang编译,而不是用gcc编译。我直观地理解正在发生的事情并能够帮助这个人,但这让我想知道——根据标准,哪个编译器是正确的?这是代码的简化版本:#include#includeclassfoo{public:foo(conststd::string&x):name(x){}foo&operator()(conststd::string&x){std::cout使用clang++可以正常编译,但是g++给出以下错误:runme.cpp:Infunction‘intmain()’:runme.cpp:21:11:error:conflicting

c++ - g++ 拒绝,clang++ 接受 : foo(x) ("bar") ("baz");

有人拥有asked前几天为什么有些东西用clang编译,而不是用gcc编译。我直观地理解正在发生的事情并能够帮助这个人,但这让我想知道——根据标准,哪个编译器是正确的?这是代码的简化版本:#include#includeclassfoo{public:foo(conststd::string&x):name(x){}foo&operator()(conststd::string&x){std::cout使用clang++可以正常编译,但是g++给出以下错误:runme.cpp:Infunction‘intmain()’:runme.cpp:21:11:error:conflicting

c++ - 为什么在函数内初始化外部变量会出错?

这段代码编译得很好:externinti=10;voidtest(){std::cout虽然这段代码给出了错误:voidtest(){externinti=10;std::couterror:'i'hasboth'extern'andinitializer我在C++Primer中读到了这篇文章:Anydeclarationthatincludesanexplicitinitializerisadefinition.Wecanprovideaninitializeronavariabledefinedasextern,butdoingsooverridestheextern.Anexte

c++ - 为什么在函数内初始化外部变量会出错?

这段代码编译得很好:externinti=10;voidtest(){std::cout虽然这段代码给出了错误:voidtest(){externinti=10;std::couterror:'i'hasboth'extern'andinitializer我在C++Primer中读到了这篇文章:Anydeclarationthatincludesanexplicitinitializerisadefinition.Wecanprovideaninitializeronavariabledefinedasextern,butdoingsooverridestheextern.Anexte

ruby - 检查警告 : Cannot find declaration for field

菜鸟问题。我对包含此类的文件运行了RubyMine的代码检查。classSquareattr_accessor:widthdefarea@width*@widthendend我很惊讶地在@width*@width行收到两个警告:找不到字段“@width”的声明attrsectionoftheStyleGuide对我没有帮助。为什么这是一个警告?----编辑----Ruby-Doc说到attr-accessorDefinesanamedattributeforthismodule,wherethenameissymbol.id2name,creatinganinstancevariabl