小编Jam*_*les的帖子

禁用emscripten中的链接libc

我很好奇是否有可能让emscripten构建一个没有libc的二进制文件.

如果我有simple.c:

int add1(int x) {
    return x + 1;
}
Run Code Online (Sandbox Code Playgroud)

而且我不想包含任何libc,这可能吗?

到目前为止,我最好的尝试是:

emcc simple.c -s NO_FILESYSTEM=1 -s DISABLE_EXCEPTION_CATCHING=1 -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE='[]' -s LIBRARY_DEPS_TO_AUTOEXPORT='[]' -s EXPORTED_FUNCTIONS='["add1"]' -s USE_SDL=0 -o simple.js -nostdlib
Run Code Online (Sandbox Code Playgroud)

但生成的输出仍包含malloc符号,字符串转换例程等.

我也对生成webassembly的过程感兴趣; 也就是说,我的真正目标是生成一个只包含单个函数的webassembly模块.这可能与emscripten有关吗?

emscripten asm.js webassembly

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

c ++向量问题; 通过参考传递东西

所以我检查了我的指针,我真的不确定这里出了什么问题.我通过引用修改它们的函数传递2个向量向量.这是功能:

bool imageToTips( Mat& img,
  vector<vector<int> > & fingertips,
  vector<vector<Point> > & hand,
  double epsilon,
  double theta){
      //code 
}
Run Code Online (Sandbox Code Playgroud)

这就是所谓的地方:

Mat depth = _depth;
Mat image = depth.clone();
Mat decon = depth.clone();
vector<vector<int> >  fingertips();
vector<vector<Point> >  hands();
double epsilon = 50;
double theta = 30;
if (fs::imageToTips(decon, fingertips, hands, epsilon, theta)) 
{
    drawContours(image, hands, -1, Scalar(255,0,0,0));
    imshow("KinectFingerProcessing", image);
    //more code
}
Run Code Online (Sandbox Code Playgroud)

错误:

/FingerLocator2/main.cpp:47: error: invalid initialization of non-const reference of type 'std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&' …
Run Code Online (Sandbox Code Playgroud)

c++ pointers reference vector temporary

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

ANTLR4-动态注入令牌

所以我正在编写一个python解析器,我需要根据python语法规范动态生成INDENTDEDENT令牌(因为python不使用显式分隔符).

基本上我有一堆表示缩进级别的整数.在INDENT令牌中的嵌入式Java操作中,我检查当前缩进级别是否高于堆栈顶部的级别; 如果是的话,我就推开它; 如果没有,我打电话skip().

问题是,如果当前缩进级别与堆栈中的多个级别匹配,我必须生成多个DEDENT令牌,而我无法弄清楚如何执行此操作.

我目前的代码:(注意within_indent_blockcurrent_indent_level在其他地方管理)

fragment DENT: {within_indent_block}? (SPACE|TAB)+;

INDENT: {within_indent_block}? DENT
        {if(current_indent_level > whitespace_stack.peek().intValue()){
                 whitespace_stack.push(new Integer(current_indent_level));
                 within_indent_block = false;
         }else{
                 skip();
         }
         }
         ;    

DEDENT: {within_indent_block}? DENT
        {if(current_indent_level < whitespace_stack.peek().intValue()){
            while(current_indent_level < whitespace_stack.peek().intValue()){
                      whitespace_stack.pop();
                      <<injectDedentToken()>>; //how do I do this
            }
         }else{
               skip();
         }
         }
         ;
Run Code Online (Sandbox Code Playgroud)

我该怎么做和/或有更好的方法吗?

parsing antlr4

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