小编vas*_*sia的帖子

如何使用GDB使用SMP(对称多处理器)调试QEMU?

我是一个研究生操作系统类,我们使用QEMU模拟我们的内核,并使用gdb进行调试.调试已经足够直截了当......直到现在.如何将gdb连接到我在QEMU中运行的其他CPU?

我们的makefile允许我们在一个终端中使用"make qemu-nox"或"make qemu-nox-gdb"启动qemu,如果我们使用后者,那么使用gdb在另一个终端中使用"gdb"连接到它(在同一目录中).因此,我不太确定如何再次连接到同一个QEMU,而是连接到另一个处理器(我现在一共运行4个).

c debugging gdb qemu xv6

6
推荐指数
1
解决办法
982
查看次数

Typescript - 如何禁止两种解析为相同类型的类型别名互换使用?

假设我有两个或多个类型别名,例如:

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

types casting typescript typescript-typings

3
推荐指数
1
解决办法
176
查看次数

创建包含字符串和 std::endl 的变量,可在 std::cout 的输出流中使用

使用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 << …

c++ cout stringstream ostringstream c++17

3
推荐指数
1
解决办法
102
查看次数