c - "complex float"和 "float complex"都是有效的 C 吗?

标签 c

我的问题很简单:

Are both "complex float" and "float complex" valid C?

两者似乎都被 gcc 接受而没有警告。

最佳答案

complex 是 complex.h 中的一个宏,它扩展为类型说明符 _Complex。这与所有其他类型说明符一样,例如 int, bool, double。对于属于同一“组”的所有类型说明符,您可以按不同的顺序组合它们。这是由 C11 6.7.2 指定的,强调我的:

At least one type specifier shall be given in the declaration specifiers in each declaration, and in the specifier-qualifier list in each struct declaration and type name. Each list of type specifiers shall be one of the following multisets (delimited by commas, when there is more than one multiset per item); the type specifiers may occur in any order, possibly intermixed with the other declaration specifiers.

然后是有效的类型说明符组列表,我们在其中找到

  • float _Complex
  • double _Complex

这意味着同一组中的说明符的任何排列都可以。


再举个例子,有一个群

  • unsigned long long, or unsigned long long int

这给了我们以下可能的组合:

unsigned long long x;
long unsigned long y;
long long unsigned z;

unsigned long long int a;
unsigned long int long b;
unsigned int long long c;
int unsigned long long d;
long unsigned long int e;
long long unsigned int f;
long long int unsigned g;
long unsigned int long h;
...

这些都是同一个意思。

关于c - "complex float"和 "float complex"都是有效的 C 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41679086/

相关文章:

c - 查找并替换文件中的单词,如何避免将整个文件读入缓冲区?

c - Windows 到 Linux 的 Port C 项目

c - 如何使用 C 中的文件打印结构

c - 从 linux c 中的文件描述符重定向 stdin

c - 使用 isalpha 和空白去除

c - 在 excel() 中打开 .txt 文件

c - 字符串数组初始化

c - read() 系统调用实际读取的数据量

c - C 中的无符号和有符号整数

java - 如何使用控制台输出来调试 pthread 与 JNI 的交互?