-4

I am using Borland C++Builder 3.

I have included math.h in my code.

When using this code:

float b;   
b=pi();

I get the following compiler error:

call to undefined function pi()

Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94
Rowland
  • 1
  • 1

1 Answers1

1

Use the M_PI constant, not the pi() function.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
cptwonton
  • 500
  • 3
  • 16
  • There is no `M_PI` in the C++ standard. – lisyarus Jan 25 '18 at 19:20
  • 2
    @lisyarus: true, but `math.h` is not a C++ header to begin with, it is C header, and `M_PI` is defined in `math.h` nonetheless, in many C/C++ compilers including Borland's. It is a common extension, if not standardized – Remy Lebeau Jan 25 '18 at 19:22
  • 2
    @RemyLebeau True, but the question in tagged with `c++`. Anyways, `M_PI` is not part of the C standard either. I believe that an explanation of what `M_PI` actually is (probably with a link that François Andrieux have posted) is needed here, not just "use M_PI". – lisyarus Jan 25 '18 at 19:28
  • 1
    @lisyarus: it is also tagged with `c++builder` and `c++builder-3`, and these do define `M_PI`. So for a question tagged with these tags, the answer is right and does not need any extra explanation. It is a simple constant with a well known value, after all. – Rudy Velthuis Jan 30 '18 at 21:08