我收到关于函数参数的警告,表明此处的类型转换正在将 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/