小编the*_*ver的帖子

写作然后根据C标准未定义阅读不同的工会成员?

我读到这个代码是根据c标准未定义但我无法找到原因.它在gcc 8.1.0和clang-6.0中编译没有错误并打印1.

代码如下:

#include <stdio.h>

int main()
{
   union {
     int i;
     short s;
   } u;  
   u.i = 42;
   u.s = 1;

   printf("%d\n", u.i);
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

c language-lawyer

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

Is there any difference between this two macros?

I find no difference between these two macros except the parentheses surrounding the macro in the first one.

Is it a matter of readability or is it a way to deal with the priority of operators?

#define TAM_ARRAY(a) (sizeof(a)/sizeof(*a))
#define TAM_ARRAY2(a) sizeof(a)/sizeof(*a)
Run Code Online (Sandbox Code Playgroud)

c c-preprocessor

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

标签 统计

c ×2

c-preprocessor ×1

language-lawyer ×1