小编cur*_*wei的帖子

关于 Cargo.toml 依赖项中的 toml 换行

我编写 Cargo.toml 的依赖项:

\n\n
[dependencies ]\nopencv = {version = "0.26", default-features = false, features = ["opencv-41"]}\n
Run Code Online (Sandbox Code Playgroud)\n\n

以上一行即可编译通过。

\n\n

我想分隔依赖关系的行。

\n\n

此页面\n https://github.com/BurntSushi/toml-test/blob/master/tests/valid/multiline-string.toml

\n\n

说解决方案。

\n\n

我参考这个解决方案来编写我的依赖项:

\n\n
[dependencies ]\nopencv = """\\{version = "0.26", \\\ndefault-features = false, \\\nfeatures = ["opencv-41"] \\\n}"""\n
Run Code Online (Sandbox Code Playgroud)\n\n

但编译器抛出错误:

\n\n
$ cargo build                                          [\xc2\xb1master \xe2\x97\x8f]\n\nerror: failed to parse manifest at /home/curlywei/WorkSpace/rust/testcargo/Cargo.toml\n\nCaused by:\n  failed to parse the version requirement { version = "0.26", default-features = false, features = ["opencv-41"] } for dependency opencv\n\nCaused by:\n  the given version …
Run Code Online (Sandbox Code Playgroud)

rust-cargo toml

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

“汇编语言”的“mov”意味着复制或移动?

最近读了std::mov的C++,想到一个问题作为标题。

假设初始值如下:

int a= 1;
int b= 2;
Run Code Online (Sandbox Code Playgroud)

我认为:

情况一、

移动后(a <- b):

a= 2 , b=  
Run Code Online (Sandbox Code Playgroud)

b 为空,因为已移动

情况2,

复制后(a <- b):

a=2  , b=2 
Run Code Online (Sandbox Code Playgroud)

我知道C++的std::move是情况1

汇编语言的情况是movmov %b %a) 。?

这是我的问题。

c++ assembly move mov

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

C: int 或 unsigned int 我用于指针增加的类型

对于这种情况:

int arr[] = {0, 1, 2};
void func (int* arr_in){
  int offset_0 = 0;
  int offset_1 = 1;
  int offset_2 = 2;
  printf("%d\n", *(arr_in + offset_0) );
  printf("%d\n", *(arr_in + offset_1) );
  printf("%d\n", *(arr_in + offset_2) );
}
Run Code Online (Sandbox Code Playgroud)

编译器不会抱怨我使用的是int还是unsigned.

两个结果似乎也正确。

int arr[] = {0, 1, 2};
void func (int* arr_in){
  int offset_0 = 0;
  int offset_1 = 1;
  int offset_2 = 2;
  printf("%d\n", *(arr_in + offset_0) );
  printf("%d\n", *(arr_in + offset_1) );
  printf("%d\n", *(arr_in + …
Run Code Online (Sandbox Code Playgroud)

c pointers integer pointer-arithmetic

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

About warning: "note: expected 'const int **' but argument is of type 'int **'"

I coding for "pass dynamic 2D to function" with C.

The following code compiles successfully and runs fine.

void iter_2d(const int** arr, 
             const size_t row, 
             const size_t column) {
// ..some code
}

int main(){
  const size_t column = 3, row = 4;
  int** arr = (int**)malloc(sizeof(int*) * row);
  for (size_t i = 0; i < row; i++)
    arr[i] = (int*)malloc(sizeof(int) * column);
  // init val for array
  iter_2d(arr,row,column);
  // clear array

}
Run Code Online (Sandbox Code Playgroud)

but I get warning:

t.c:24:11: warning: passing …
Run Code Online (Sandbox Code Playgroud)

c

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

标签 统计

c ×2

assembly ×1

c++ ×1

integer ×1

mov ×1

move ×1

pointer-arithmetic ×1

pointers ×1

rust-cargo ×1

toml ×1