1

Does anyone know if an underscore as format specifier (like %_f) does anything in C code? I+ve found some code in a book that uses it, but I've googled and found nothing. I've also tested the following Objective-C code in Xcode and Xcode seems not to support this specifier. Is it valid in C?

-(void) print {
    printf( "%_f + %_fi", real, imaginary );
}

Thanks!

1 Answers1

5

The OS X man page for printf() says this:

  • An optional separator character ( , | ; | : | _ ) used for separating multiple values when printing an AltiVec or SSE vector, or other multi-value unit.

    NOTE: This is an extension to the printf() specification. Behaviour of these values for printf() is only defined for operating systems conforming to the AltiVec Technology Programming Interface Manual. (At time of writing this includes only Mac OS X 10.2 and later.)

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • 1
    I think this is not the case, as we are printing doubles, not vectors. – João Correia Nov 09 '14 at 18:13
  • 1
    The separator is used by `printf()` "when printing an AltiVec or SSE vector, or other multi-value unit". When not printing such a multi-value unit, it presumably is not used. The presence or absence of the "v" length modifier is what determines if the argument is interpreted as a vector value. (See further down the man page.) So, effectively, the underscore does nothing in this case. – Ken Thomases Nov 09 '14 at 18:22