So here is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
float f = .55;
int i;
i = round(f);
}
The first problem I am having is the round() function itself. When calling it like this: round(foo) There are no compile errors. Of coarse, this is useless as the desired output of round() is returned. But when I try to capture the output of round() like this:
i = round(f)
I get a compile time error:
test.c:(.text+0x1b): undefined reference to `round'
It is as though just trying to assign the return value of round() is forcing round() to not be defined. I have read some posts on here that said I should pass -lm to GCC, but this makes no difference.
Trying to call round() from printf gives me the same error such as:
printf("....", round(f))
This is literally driving me mad at the moment because all online references say:
int i = round(f)
Should work.
This is the latest GCC on Ubuntu 18.04.