Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:15:10+00:00 2026-05-25T11:15:10+00:00

I would like to compile a simple C90 code utilizing math library: main.c: #include

  • 0

I would like to compile a simple C90 code utilizing math library:

main.c:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

int main()
{
  printf("M_PI: %f\n", M_PI);
}

I use GCC compiler and use option -ansi -pedantic to enforce C90 standard.

gcc -ansi -pedantic -lm main.c

But it doesn’t compile. The following is the error message:

main.c: In function ‘main’:
main.c:7:25: error: ‘M_PI’ undeclared (first use in this function)
main.c:7:25: note: each undeclared identifier is reported only once for each function it appears in

My question is, why? Does C90 standard prohibits the use of math library?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:15:11+00:00Added an answer on May 25, 2026 at 11:15 am

    M_PI isn’t defined when strict iso standard is required. Look on this page under trigonometric functions. It is suggested that when using -ansi, just define it yourself:

    #define M_PI 3.14159265358979323846264338327
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to take all my simple math programs for basic financial ratios
I would like to compile a DLL under Visual Studio 2008 that depends on
I would like to make a very simple ant script that does 1 thing,
I have a rather simple C project I compile with make that I would
I am using Visual Studio 2010 Pro for simple C programming, I would like
Is there a simple line of code that would allow only loading the code
I would like to write an OCaml module having a compile function which will
I have some code available in some form of AST and I would like
I have this very simple piece of code; #include <deque> #include <vector> using namespace
I'm fine working on Linux using gcc as my C compiler but would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.