Bada IDE 有代码补全和有意义的错误消息吗?
我正在尝试将 Bada 应用程序从 1.2 升级到 2.0,但没有 Bada 经验。我已经构建了项目,并且可以在模拟器中运行它,但我收到了大量警告,并且无法单击文本框来获取键盘并在模拟器中输入任何内容。
不幸的是,警告消息对我来说完全神秘,例如
SearchForm::SearchForm(void) :
给出警告消息“此处初始化时”
此处初始化时会发生什么?
另外,所有 TryCatch 语句都显示语法错误,并且我在互联网上找到的任何内容似乎都没有让它满意:
result OnDraw()
{
result r = E_SUCCESS;
Canvas* readerCanvas = GetCanvasN();
TryCatch(E_SUCCESS == GetLastResult(), "Failed to get canvas: %S", GetErrorMessage(r));
if (readerCanvas)
{
Rectangle tempRect(0, 0, GetBounds().width, GetBounds().height);
Point tempPoint(0, 0);
r = readerCanvas->Copy(tempPoint, *iDrawingCanvas, tempRect);
TryCatch(E_SUCCESS == r, "Failed to copy canvas: %S", GetErrorMessage(r));
delete readerCanvas;
}
return r;
CATCH:
delete readerCanvas;
return r;
}
TryCatch 行说“语句无效”,如果我尝试编辑它以匹配我发现的示例语法错误。
这是怎么回事?
I'm trying to upgrade a Bada app from 1.2 to 2.0 with no experience of Bada. I have the project building and can run it in the emulator but I get a load of warnings and I cant click the text boxes to get a keyboard and enter anything in the emulator.
Unfortunately the warning messages are completely cryptic to me, for example
SearchForm::SearchForm(void) :
gives the warning message "when initialized here"
What when initialized here??!!
Also, all the TryCatch statements show syntax error, and nothing I have found on the internet seems to make it happy:
result OnDraw()
{
result r = E_SUCCESS;
Canvas* readerCanvas = GetCanvasN();
TryCatch(E_SUCCESS == GetLastResult(), "Failed to get canvas: %S", GetErrorMessage(r));
if (readerCanvas)
{
Rectangle tempRect(0, 0, GetBounds().width, GetBounds().height);
Point tempPoint(0, 0);
r = readerCanvas->Copy(tempPoint, *iDrawingCanvas, tempRect);
TryCatch(E_SUCCESS == r, "Failed to copy canvas: %S", GetErrorMessage(r));
delete readerCanvas;
}
return r;
CATCH:
delete readerCanvas;
return r;
}
The TryCatch line says "statement has no effect", if I try edit it to match the examples I'v found I get a syntax error.
What's up with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您正试图通过完全断章取义且仅部分引用来超越 IDE 所谓的不良消息。让我来分解一下:
TryCatch
宏定义为
当条件评估为 false 时,这将转到 CATCH。您可以这样想宏:
例如,您可以这样使用它:
现在,您的第二个参数是一个字符串文字,
“Failed to get canvas: %S”
,毫不奇怪,它不会用作语句时没有效果:因此编译器会很好地警告您您可能有其他想法。另请注意,
语句无效
不是语法错误。“当在这里初始化时”
了解你的语言!引用的代码一开始就不是合法的 C++:
充其量这是构造函数定义的开头,缺少初始值设定项列表和主体。在 C++ 语言规范中,类成员按照声明的顺序进行初始化,而不是按照它们在初始化列表中出现的顺序进行初始化。一个最小的例子:
这会导致编译器警告:
如您所见,您不仅剪辑了代码,还剪辑了警告!如果您阅读了整个消息和整个代码,修复将非常明显:
奖励:如果您想知道为什么顺序很重要,请考虑当您这样做时会发生什么:
希望这会
有所 帮助使用宏
编辑格式化字符串我刚刚注意到这一点:可能不支持在 Try/Catch 宏中使用格式字符串:
It seems like you are trying to outdo your IDE's supposed bad messages by quoting them entirely out of context and only partially. Let me break it down:
TryCatch
The macro is defined as
When the condition is evaluated to false, this will goto CATCH. You could think of the macro like this:
For example, you can use it like this:
Now, your second parameter is a string literal,
"Failed to get canvas: %S"
, which unsurprisingly, doesn't have an effect when used as statement:So the compiler is being nice to warn you of the fact that you probably had something else in mind. Note also, that
statement has no effect
is not a syntax error."when initialized here"
Know your language! The code quoted isn't legal C++ to begin with:
At best this is the beginning of a constructor definition, with a missing initializer list and body. In the C++ language spec, class members are initialized in the order in which they were declared, not in the order in which they appear in the initializer list. A minimal example:
This results in the compiler warning:
As you can see, you not only clipped the code but also the warnings! If you read the whole message and the whole code, the fix would be pretty obvious:
Bonus: In case you were wondering, why the ordering matters, consider what happens when you do:
Hope this helps
Using a Format String with the Macros
Edit I just noted this: it is probably not supported to use format strings inside the Try/Catch macros: