I have the following function in my code:
int numberOverflow(int bit_count, int num, int twos) {
int min, max;
if (twos) {
min = (int) -pow(2, bit_count - 1); \\ line 145
max = (int) pow(2, bit_count - 1) - 1;
} else {
min = 0;
max = (int) pow(2, bit_count) - 1; \\ line 149
}
if (num > max && num < min) {
printf("The number %d is too large for it's destination (%d-bit)\n", num, bit_count);
return 1;
} else {
return 0;
}
}
At compile time I get the following warning:
assemble.c: In function ‘numberOverflow’:
assemble.c:145: warning: incompatible implicit declaration of built-in function ‘pow’
assemble.c:149: warning: incompatible implicit declaration of built-in function ‘pow’
I'm at a loss for what is causing this... any ideas?
On some online compilers, the following error may occur. The above error occurs because we have added “math. h” header file, but haven't linked the program to the following math library. Link the program with the above library, so that the call to function pow() is resolved.
a . You need to link your program with this library so that the calls to functions like pow() are resolved. This solved my issue.
C pow() The pow() function computes the power of a number. The pow() function takes two arguments (base value and power value) and, returns the power raised to the base number. For example, [Mathematics] xy = pow(x, y) [In programming] The pow() function is defined in math.
C library function - pow() The C library function double pow(double x, double y) returns x raised to the power of y i.e. xy.
You need to include math.h
And why exactly do we get this warning?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With