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

486
Views
C program: implicit declaration of function and conflicting types

Here's a function calculating the division of two numbers. All variables and functions are declared as float. However, the code below does not compile and the error message shows that "%f expects argument of type double, but argument has type int" and "implicit declaration of function 'div'" and "conflicting types for 'div'".

#include <stdio.h>
#include <assert.h>

float div(float a, float b);

int main() {
  float a = 5;
  float b = 8;
  printf("%f divided by %f is %f \n", a, b, div(a, b));
}

float div(float a, float b) { 
  assert(b != 0);
  return a / b;
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The 2018 C standard discusses the standard library in clause 7. C 2018 7.1.3 1 says:

… All identifiers with external linkage in any of the following subclauses (including the future library directions) and errno are always reserved for use as identifiers with external linkage.

In one of the following subclauses, 7.22.6.2, div is described as a function, and hence as an identifier with external linkage.

Therefore, it is reserved for use as the name of a standard library routine, and the behavior of a program that uses it for another purpose is not defined by the C standard.

Rename your function.

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!