我将Android SDK工具从版本11更新到版本12,现在仿真器无法启动.当我尝试运行emulator.exe时,我得到:
无效的命令行参数:Files\Android\android-sdk\tools/emulator-arm.exe.
提示:使用'@foo'启动名为'foo'的虚拟设备.
请使用-help获取更多信息
emulator.exe的路径是C:\ Program Files\Android\android-sdk\tools.
我如何解决它?
我想将一个rvalue传递std::bind给一个在C++ 0x中采用rvalue引用的函数.我无法弄清楚该怎么做.例如:
#include <utility>
#include <functional>
template<class Type>
void foo(Type &&value)
{
Type new_object = std::forward<Type>(value); // move-construct if possible
}
class Movable
{
public:
Movable(Movable &&) = default;
Movable &operator=(Movable &&) = default;
};
int main()
{
auto f = std::bind(foo<Movable>, Movable());
f(); // error, but want the same effect as foo(Movable())
}
Run Code Online (Sandbox Code Playgroud) 我一直认为,由于JavaScript是单线程的,我可以附加事件处理程序而不必担心处理程序在执行代码时会被执行.令我惊讶的是,我发现他们可以.根据这个答案, "无响应脚本"对话框可能会导致在脚本仍在运行时引发事件.
我用以下代码测试了这个:
<script>
function loop() {
var cond;
onblur = function (event) {
cond = false;
};
cond = true;
while (cond)
;
alert('loop exited!');
}
</script>
<button onclick="loop()">loop()</button>
Run Code Online (Sandbox Code Playgroud)
在Firefox 11.0中,该功能在单击"继续"后打印"循环退出".循环似乎暂停,允许执行事件.这类似于Unix信号,它暂时改变目标线程的上下文.但它更危险,因为它允许外部状态被改变.
这是一个错误吗?我是否应该不再依赖JavaScript的单流执行模型并确保我的所有脚本都是可重入的?或者这是一个不值得追求的缺陷,尽管主流浏览器允许这种情况发生?
我正在使用Boost.Asio在C++中编写跨平台服务器程序.遵循此页面上的HTTP Server示例,我想在不使用特定于实现的API的情况下处理用户终止请求.我最初尝试使用标准C信号库,但一直无法找到适合Asio的设计模式.在Windows示例的设计似乎像最近的信号库,但有一个竞争条件,其中服务器对象已被破坏后控制台CTRL处理程序可以调用.我试图避免C++标准规定的未定义行为.
是否有标准(和正确)方法来停止服务器?
为了说明使用C信号库的问题:
#include <csignal>
#include <functional>
#include <boost/asio.hpp>
using std::signal;
using boost::asio::io_service;
namespace
{
std::function<void ()> sighandler;
}
extern "C"
{
static void handle_signal(int);
}
void handle_signal(int)
{
// error - undefined behavior
sighandler();
}
int main()
{
io_service s;
sighandler = std::bind(&io_service::stop, &s);
auto old_sigint = signal(SIGINT, &handle_signal);
if (old_sigint == SIG_IGN)
// race condition? raise SIGINT before I can set ignore back
signal(SIGINT, SIG_IGN);
auto old_sigterm = signal(SIGTERM, &handle_signal);
if …Run Code Online (Sandbox Code Playgroud) 假设我需要int32_t使用printf格式说明符打印格式化的字符串<inttypes.h>.
int32_t i = 0;
printf("%" PRId32 "\n", i);
Run Code Online (Sandbox Code Playgroud)
如果我尝试在Visual C++ 2013中对宽字符执行相同操作,则会失败:
#define W_(val) L ## val
#define W(val) W_(val)
wprintf(L"%" W(PRId32) L"\n", i);
Run Code Online (Sandbox Code Playgroud)
错误C2308:连接不匹配的字符串
如何将宽字符串文字与格式转换说明符宏连接?
c++ ×2
android ×1
boost-asio ×1
c ×1
c++11 ×1
concurrency ×1
javascript ×1
macros ×1
rvalue ×1
signals ×1
std ×1
string ×1
unicode ×1
visual-c++ ×1