English 中文(简体)
How to avoid misformatting of binary values with GNU indent?
原标题:

When GNU indent (at least version 2.2.6 and 2.2.10) is used on the following code...

void
main ()
{
  int i = 0b01010101;
}

it will be reformatted into this ...

void
main ()
{
  int i = 0 b01010101;
}

Is there any option in indent that avoids this behavior?

最佳回答

I got an answer to this question on the indent mailing list:

No intent doesn t support C derivatives: that construct isn t C.

The Binary constants using the `0b prefix is just an extension of gcc.

问题回答
#!/bin/sh

indent | sed -r  s/(0) (b[01]+)/12/g 




相关问题
C++ GNU linker errors

I m trying to compile my program on Windows via Cygwin with the compilation command: g++ ping.cpp -I./include -L./lib -lchartdir50 I m using an API called ChartDirector which draws charts for me. I ...

How to avoid misformatting of binary values with GNU indent?

When GNU indent (at least version 2.2.6 and 2.2.10) is used on the following code... void main () { int i = 0b01010101; } it will be reformatted into this ... void main () { int i = 0 b01010101;...

热门标签