Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
GCC: ¿por qué no se puede compilar clean printf("%f\n", f16) bajo -std=c11 -Wall?

Código de muestra:

 #include <stdio.h> #define __STDC_WANT_IEC_60559_TYPES_EXT__ #include <float.h> #ifdef FLT16_MAX _Float16 f16; int main(void) { printf("%f\n", f16); return 0; } #endif

Invocación:

 # gcc trunk on linux on x86_64 $ gcc t0.c -std=c11 -Wall

Diagnósticos esperados:

 <nothing>

Diagnósticos reales:

 t0.c:9:14: warning: format '%f' expects argument of type 'double', but argument 2 has type '_Float16' [-Wformat=] 9 | printf("%f\n", f16); | ~^ ~~~ | | | | | _Float16 | double

¿Significa que bajo __STDC_WANT_IEC_60559_TYPES_EXT__ Y si FLT16_MAX definió, el gcc no sabe que printf se puede usar con _Float16 ? ¿Debe ser consciente?

También: printf("%f\n", f); cuando f es un float no genera ninguna advertencia a pesar de que el format '%f' expects argument of type 'double', but argument 2 has type 'float' . Confundido.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Del manual clang :

Dado que la promoción de argumentos predeterminada solo se aplica a los tipos de punto flotante estándar, los valores _Float16 no se promocionan al double cuando se pasan como argumentos variables o sin tipo. Como consecuencia, se debe tener cierta precaución al usar ciertas funciones de la biblioteca con _Float16 ; por ejemplo, no existe un especificador de formato printf para _Float16 y (a diferencia de float ) no se promoverá implícitamente a double cuando se pase a printf , por lo que el programador debe convertirlo explícitamente en double antes de usarlo con un %f o un especificador similar.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!