Working on a mac and getting an 'undefined symbols' error when I try to compile this push pop program. I don't see a problem in my code; I'm wondering if it could be a problem with the gcc version I have? If anyone can help it would be most appreciated
Here's my code:
Code:
#include <stdio.h>
#include <stdlib.h> /* for atof() */
#define MAXOP 100 /* max size of operand or operator */
#define NUMBER '0' /* signal that a number was found */
int getop (char []);
void push (double);
double pop (void);
/* reverse Polish calculator */
main()
{
int type;
double op2;
char s[MAXOP];
while ((type = getop(s)) != EOF)
{
switch (type)
{
case NUMBER:
push (atof(s));
break;
case '+':
push(pop() + pop());
break;
case '*':
push(pop() * pop());
break;
case '-':
push(pop() - op2);
break;
case '/':
op2 = pop();
if (op2 != 0.0)
push(pop() / op2);
else
printf("error: zero divisor\n");
break;
case '\n':
printf("\t%.8g\n", pop());
break;
default:
printf("error: unknown command %s\n", s);
break;
}
}
return 0;
}
Here's my error:
Code:
/usr/bin/ld: Undefined symbols:
_getop
_pop
_push
collect2: ld returned 1 exit status