我是一个研究生操作系统类,我们使用QEMU模拟我们的内核,并使用gdb进行调试.调试已经足够直截了当......直到现在.如何将gdb连接到我在QEMU中运行的其他CPU?
我们的makefile允许我们在一个终端中使用"make qemu-nox"或"make qemu-nox-gdb"启动qemu,如果我们使用后者,那么使用gdb在另一个终端中使用"gdb"连接到它(在同一目录中).因此,我不太确定如何再次连接到同一个QEMU,而是连接到另一个处理器(我现在一共运行4个).
假设我有两个或多个类型别名,例如:
declare type A = string;
declare type B = string;
Run Code Online (Sandbox Code Playgroud)
我有这些类型的变量,以及对它们进行操作的函数。
const a1: A = "example of a";
const b1: B = "example of b";
function withA(a: A){
console.log(a);
}
function withB(b: B){
console.log(b);
}
Run Code Online (Sandbox Code Playgroud)
我希望以下代码出错,但不会:
withA(b1);
withB(a1);
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我还需要能够用字符串初始化变量(我假设是强制转换)。但是,一旦初始化,我不希望这些类型“隐式等效”,并且希望编译器禁止它们的互换使用。
我也不想使用类,如下所述: TypeScript - specific string types
使用c++17
我有一个头文件colors.hpp来帮助我将彩色输出到标准输出:
#pragma once
#include <string>
namespace Color
{
static const std::string yellow = "\u001b[33m";
static const std::string green = "\u001b[32m";
static const std::string red = "\u001b[31m";
static const std::string end = "\u001b[0m";
}
Run Code Online (Sandbox Code Playgroud)
我经常这样使用它:
std::cout << Color::green << "some green text " << Color::end << std::endl;
Run Code Online (Sandbox Code Playgroud)
我几乎总是紧随std::endl其后Color::end。我希望能够实现相同的结果(换行+缓冲区刷新),但仅使用一个变量 - 例如Color::endl.
我只能提出解决方案string,据我所知,这些解决方案将包含该\n字符,但也不会强制刷新到标准输出。
static const std::string endl = std::ostringstream(static_cast<std::ostringstream &&>(std::ostringstream() << Color::end << std::endl)).str();
Run Code Online (Sandbox Code Playgroud)
如果我从上面的代码中删除.str(),那么我就不能这样做:
std::cout << …