Compilation error: This was just carelessness.
getop.c:31:6: error: conflicting types for 'getOp' char getOp(const char *op) { ^ ./calc.h:3:5: note: previous declaration is here int getOp(const char *s); ^ 1 error generated.
Error handling: You treat errors like warnings. If there's an error, I would expect the program to print nothing to stdout, and for the program to exit with a non-zero status code. Error and warning messages should be printed to stderr instead of stdout.
Picky validation: In my opinion, this should successfully evaluate to 1:
$ ./calcexpr 1 invalid call
By the way, if you find an insufficient number of command-line arguments, just return early.
int main(int argc, char *argv[]) { if (argc <= 1) { fprintf(stderr, "invalid call\n"); return 1; } while (--argc) { … } printf("%g\n", pop()); return 0; }
Mishandling of negative numbers: I would expect the following calculation to yield -1:
$ ./calcexpr 3 -4 + warning: the stack is freewarning: the stack is free-3
Unconventional division operator: It is customary to use
/
for division. I don't know why you use\
instead.Division-by-zero paranoia: In contrast to integer arithmetic, where division by zero is undefined behaviour, division by zero in IEEE 754 floating point arithmetic should just return infinity. Perhaps you could remove the check for division by zero.