小编Ank*_*zle的帖子

GitHub 文件夹上有一个白色箭头

我最近推送到 github,并在我的一个文件夹上看到一个白色箭头。

在此处输入图片说明

当我单击文件夹时,它不会打开它。在我的本地机器上,它有内容,但在 github 中我无法访问它们。这是什么意思?

git github

62
推荐指数
7
解决办法
4万
查看次数

使用 swig 从 C++ 调用 go

我正在使用 swig 将 c++ 与 go 链接起来,但我想在我的 c++ 代码中使用 go 函数。我以前使用过 cgo,并且知道这样的东西会起作用:

//bind.h
extern void GoFunc(*C.char);
void CFunc();
//////////////////


//bind.cc
void CFunc() {
  //do stuff
}
//////////////////


//main.go
package main

//#include "bind.h"
import "C"

//export GoFunc
func GoFunc(*C.char) {
  //do go stuff
}

func main() {
  C.CFunc()
}
//////////////////
Run Code Online (Sandbox Code Playgroud)

但当我尝试在痛饮中复制这一点时,

//bind/bind.i
%module bind
%{
  extern void Foo();
  #include "bar.hpp"
%}

%include <typemaps.i>
%include "bar.hpp"
///////////////////////////


//bind/bar.hpp
class Bar {
  Bar() {}
  void Call() {
    Foo();
  }
};
///////////////////////////


//main.go
package …
Run Code Online (Sandbox Code Playgroud)

c++ swig go cgo

5
推荐指数
0
解决办法
582
查看次数

Node.js process.stdout.write 在 for 循环中闪烁

我正在制作一个控制台界面,并使用 for 循环。

for (let i = 0; i < 100000; i++) {
  process.stdout.clearLine();
  process.stdout.cursorTo(0);
  process.stdout.write('Something: ' + i);
}
Run Code Online (Sandbox Code Playgroud)

当我使用它时,'Something: i'闪烁。有什么办法可以让它不闪烁吗?

编辑:我正在使用 Windows 命令提示符,有没有办法防止那里闪烁?

console node.js

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

nlohmann 的 json 库将数组转换为结构向量

假设我有一个如下所示的 json 数组:

[
  {
    "Name": "test",
    "Val": "test_val"
  },
  {
    "Name": "test2",
    "Val": "test_val2"
  }
]
Run Code Online (Sandbox Code Playgroud)

我想将其转换为结构向量:

struct Test {
  string Name;
  string Val;
};
Run Code Online (Sandbox Code Playgroud)

我知道该json.get<>()方法,但不知道如何应用到此。

c++ json nlohmann-json

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

req.body.username 未定义

在 express js 中,我使用正文解析器来获取用户名。当我尝试获取用户名时,它返回未定义。谁能帮我?

app.use(session({
 cookieName: 'session',
 secret: "Shh_It's_a_secret",
 duration: 100000 * 100000
}));
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/home', (req, res) => {
if(req.body.username){
 res.send('Invalid Username, Press The Back Button To Try Again');
} else if (!req.body.username) {
  app.use(express.static(__dirname + '/NerdFestProjectHomepage.html'));
  res.sendfile('NerdFestProjectHomepage.html');
  console.log(req.body.username);
}
})
Run Code Online (Sandbox Code Playgroud)

当我尝试获取 req.body.username 时,它​​返回未定义。

node.js express body-parser

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

在内联 C 汇编中执行系统调用会导致段错误

我最近涉足低级编程,并希望制作一个somesyscall接受(CType rax, CType rbx, CType rcx, CType rdx). struct CType 看起来像:

/*
    TYPES:
        0 int
        1 string
        2 bool
*/
typedef struct {
    void* val;
    int typev;
} CType;
Run Code Online (Sandbox Code Playgroud)

该功能有点混乱,但理论上应该可以工作:

#include <errno.h>
#include <stdbool.h>
#include "ctypes.h"

//define functions to set registers
#define seteax(val) asm("mov %0, %%rax" :: "g" (val) : "%rax")
#define setebx(val) asm("mov %0, %%rbx" :: "g" (val) : "%rbx")
#define setecx(val) asm("mov %0, %%rcx" :: "g" (val) : "%rcx")
#define setedx(val) asm("mov %0, %%rdx" …
Run Code Online (Sandbox Code Playgroud)

c ubuntu assembly system-calls

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

标签 统计

c++ ×2

node.js ×2

assembly ×1

body-parser ×1

c ×1

cgo ×1

console ×1

express ×1

git ×1

github ×1

go ×1

json ×1

nlohmann-json ×1

swig ×1

system-calls ×1

ubuntu ×1