Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

521
Visualizações
format '%lld' expects type 'long long int', but argument 4 has type 'int64_t'

I try to print a variable of type int64_t using %lld format specifier but get the following warning?

Warning: format '%lld' expects type 'long long int', but argument 4 has type 'int64_t'

In my opinion, under linux, the int64_t is always long long int, then:

  1. Why does this warning occur?
  2. How can I fix this?
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

how to fix?

Use PRId64: (Don't forget to include <inttypes.h>)

printf("var64 = %" PRId64 "\n", var64);

Use PRIx64 and proper cast if you want to print it as hex.

int64_t is always long long int, then why does this warning occur?

C99 onwards (link to draft, Page 22), C specs suggest the type long long int should be atleast 64 bits but it may be more also.

— minimum value for an object of type long long int
LLONG_MIN -9223372036854775807 // −(263−1)
— maximum value for an object of type long long int
LLONG_MAX +9223372036854775807 // 263− 1

On some platforms, long long int might be 128-bit and the print statement invokes UB on such platforms.

So treat this warning as a portability issue warning.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda