c - 何时忽略 byte_order 更改?

标签 c

我收到关于函数参数的警告,表明此处的类型转换正在将 byte_order 从 bigendian int 更改为 int。所以我将其更改为bigendian int。但这样做会被忽略。

function_call_name((int*)&argument1, argument2));

function_call_name((int* __attribute__((bigendian))) & argument1, argument2);

尝试寻找解决方案 https://software.intel.com/en-us/node/628908

但是事情并没有进展。

我可以寻求帮助吗? :)

另外,如何知道正在运行的 byte_order 是什么。我的意思是一些 #ifdef 指令?

最佳答案

例如,如果这些(非标准)限定符类似于 const 限定符,则:

const int *a;                 // a is a pointer to const int
int const *b;                 // b is a pointer to int const (same as a)
int * const c = (int[42]){0}; // c is a const pointer to int (DIFFERENT!)

可以通过尝试修改它们来观察它们的差异:

a = (int const[]){0}; // This is allowed
a[0] = 42;            // This is NOT allowed
c = NULL;             // This is NOT allowed
c[0] = 42;            // This is allowed
<小时/>

我认为您可能想写int __attribute__((bigendian)) *,即将属性放在星号之前以表示您想要一个指针到大端int,因为将其放在之后将表示一个int的大端指针。 ..

关于c - 何时忽略 byte_order 更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45183957/

相关文章:

c - 二维数组中的指针

c - 在 c 中从字符串中解析数字比 strtok 更好的选择?

c++ - C 堆栈跟踪中缺少函数调用

c++ - 从 C 文件调用 C++ 函数

c - WM_MOUSEMOVE 消息处理

c - 使用 scanf 进行输入读取挂起

c - 传递目录作为参数并显示其最后修改日期

c++ - 使用文件锁的进程间的条件变量

处理 char 数组时处理 NULL char 的正确方法

c - 在 C 中附加失败,只是覆盖