2

I have include math.h in my .yacc file and when I am trying to use the pow function in this part of the code it is giving me the above mentioned error

expression2:expression2 POWER_OP expression3  {/*keeping POWER_OP at highest precedence*/ $$ = pow($1,$3);}

and when I tried to put 2,3 or any constant value in the same part of code it is working fine

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • 1
    You need `-lm` in your compile options if you use the math library. Nothing to do with parsing. – rici Feb 07 '18 at 13:21
  • 1
    Many of the [common mathematical functions](http://en.cppreference.com/w/c/numeric/math) are in a separate library that needs to be explicitly linked. That library is simply called `m`. I'm sure someone will come with a duplicate soon enough which is why I won't answer. – Some programmer dude Feb 07 '18 at 13:22

1 Answers1

4

Try adding -lm when compiling the files. example: gcc c.tab.c lex.yy.cc -lm

ashwinbhy
  • 600
  • 1
  • 8
  • 30