Tag: uint32

如何在Fortran中调用C函数并正确传递uint32_t参数

您好我使用Fortran 90代码来调用C函数。 由于我在操作地址,因此应该在Fortran中正确匹配C函数的参数。 我正在使用ifort和icc来编译代码并在64位机器上工作。 一些测试显示这也适用于int32_t ,虽然为了防止最终的陷阱,我想保留uint32_t 我调用的C函数有以下原型 uint32_t encode_(uint32_t x, uint32_t y) uint32_t decode_(uint32_t dec) 我不能仅仅通过做类似的事情来调用这些函数 integer :: cod,encode cod = encode(i,j) 这会产生胡言乱语。 因此我使用了一种解决方法: void code2d_(uint32_t j[] ){ uint32_t i; i=encode_(j[0],j[1]); // the underscore is due to the FORTRAN naming convention printf(“Coded %10d \n”,i); } 随后在Fortran integer :: cod,code2d cod = code2d(i,j) 显然,我对参数类型的不匹配有一些问题。 不幸的是我不知道如何解决这个问题。 由于在我的解码/编码函数中完成了二进制地址算法,因此保留uint32_t非常重要。

uint32_t vs int作为日常编程的约定

什么时候应该使用stdint.h中的数据类型? 总是使用它们作为惯例是正确的吗? 设计非特定尺寸类型(如int和short)的目的是什么?