Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

About abs() function

Altera_Forum
Honored Contributor II
1,679 Views

I want to invoke abs() function in NiosII. 

 

But i find this function does not defined. 

 

Which header file should I include? or I should implement it by myslef?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
479 Views

It should be there, as a part of newlib. Try including stdlib.h and see if that works. 

 

Here's a brief description from a website I found: 

 

Synopsis # include <stdlib.h> int abs(int i); Description abs returns the absolute value of i (also called the magnitude of i). That is, if i is negative, the result is the opposite of i, but if i is nonnegative the result is i. The similar function labs uses and returns long rather than int values. Returns The result is a nonnegative integer. Portability abs is ANSI. No supporting OS subroutines are required. 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
479 Views

That&#39;s OK. 

 

abs() is working now when i add <stdlib.h> . 

 

THX!
0 Kudos
Reply