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

219
Visualizações
gcc/clang: error: conflicting types for <function_name>: why function name matters?

Sample code (t987.c):

void *NAME();
void *NAME(void *, int, unsigned);

Invocation:

$ gcc t987.c -c -DNAME=memset1
<nothing>

$ gcc t987.c -c -DNAME=memset
<command-line>: error: conflicting types for ‘memset’; have ‘void *(void *, int,  unsigned int)’
t987.c:2:7: note: in expansion of macro ‘NAME’
    2 | void *NAME(void *, int, unsigned);
      |       ^~~~
<command-line>: note: previous declaration of ‘memset’ with type ‘void *(void *, int,  long unsigned int)’
t987.c:1:7: note: in expansion of macro ‘NAME’
    1 | void *NAME();

# clang: the same behavior

Question: why function name matters?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

There's no other definition or declaration for memset1. So these two declarations are compatible:

void *memset1();
void *memset1(void *, int, unsigned);

Because the first one says the number and type of parameters is unknown.

This however gives you a problem:

void *memset();
void *memset(void *, int, unsigned);

Because memset is defined by the C standard and therefore considered part of the implementation, it is also internaly declared as:

void *memset(void *, int,  long unsigned int)

Which conflicts with your second declaration.

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