Implicit declaration of function ABS

Source: Internet
Author: User
Tags mathematical functions

From: http://www.lampos.net/taxonomy/term/72

 

You are a beginner in C programming language (maybe 1st year student
In a computer science department) and you want to meet a deadline for
Programming assignment. The program specification is simple (because it
Is still the beginning) but there is something annoying happenning
Your source code.

The course extends uctor has forced you to compile your C Programs with all the appropriate flags enabled, e.g.

>> gcc program_name.c -ansi -pedantic -Wall -o program_name

Your program functions des mathematical functions and as a result you have included math. h Library
And you have added-LM
Flag during compilation time:

>> gcc program_name.c -ansi -pedantic -Wall -lm -o program_name

Your final program shold work
(Perfectly !) And after compilation no warnings shoshould appear.
Otherwise, you lose points on your final mark!

You have followed all the instructions, your program is working (!) But you still get an annoying warning, like:

implicit declaration of function abs

You try again and again, you 'Google 'This
Warning but there is no result. Usually, the compiler is absolutely
Right and points to the right ction (in simple programs of course ).
So, there is an implicit declation of the 'abs 'function (which returns
The absolute value of a number). Something is missing. What? The
Following line (in most of the cases ):

#include <stdlib.h>

You shoshould include stdlib. h Library
As well. Don't forget that! That's it... It shoshould have helped you! -:)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.