小编Mar*_*erg的帖子

空的初始化列表是否为有效的C代码?

通常用于{0}初始化a struct或a,array但考虑第一个字段不是标量类型时的情况.如果第一个字段struct Person是另一个struct或数组,则该行将导致错误(error: missing braces around initializer).

struct Person person = {0};
Run Code Online (Sandbox Code Playgroud)

至少GCC允许我使用空的初始化列表来完成同样的事情

struct Person person = {};
Run Code Online (Sandbox Code Playgroud)

但这是有效的C代码吗?

另外:这条线是否保证给出相同的行为,即零初始化struct

struct Person person;
Run Code Online (Sandbox Code Playgroud)

c standards gcc struct initializer

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

如何让git log剪掉长评论?

我有一个git日志别名,将每个提交打印为一行.由于有些人在提交日志中编写了太长的单行,因此许多提交都会换行到新行.如何格式化git log输出以在50个字符后剪切注释?

我在git-log手册页中找到了这个,但它只会填充简短的注释,而不会删除很长的注释.

%<(<N>[,trunc|ltrunc|mtrunc]): make the next placeholder take at least N columns,
  padding spaces on the right if necessary. Optionally truncate at the beginning (ltrunc),
  the middle (mtrunc) or the end (trunc) if the output is longer than N columns. Note that
  truncating only works correctly with N >= 2.
Run Code Online (Sandbox Code Playgroud)

git

31
推荐指数
3
解决办法
6444
查看次数

标签 统计

c ×1

gcc ×1

git ×1

initializer ×1

standards ×1

struct ×1