I am starting work on a little passion project with the hopes of having a high tech pokemon dnd campaign in the future (no idea when, just kind of working it out). I haven't programmed in a long time and this is giving me a bug I can't quite comprehend for some reason. So, here's my current code.
main.cpp ->
#include <stdio.h>
#include <math.h>
#include "calculations.c"
int main()
{
int speedAtt = 45;
int speedDef = 63;
int accuracy = 100;
int roll = findroll(speedAtt, speedDef, accuracy);
printf("Attacker needs to roll a %d\n", roll);
return 0;
}
calculations.c ->
#include <stdio.h>
#include <math.h>
#include "calculations.h"
int findroll (int speedA, int speedD, int acc)
{
int roll;
float hitperc = ((speedA / speedD) * acc) / 100;
if (hitperc >= 1)
roll = 2;
else
roll = round (20 - (hitperc * 20));
return roll;
}
int dodamage (int attk, int def, int power, int atroll)
{
return 0;
}
calculations.h ->
#ifndef CALCULATIONS_H_
#define CALCULATIONS_H_
int findroll (int, int, int);
int dodamage (int, int, int, int);
#endif
Then I get this series of errors:
/usr/bin/ld: /tmp/cc3PaZfu.o: in function `std::round(float)':
/home/calculations.c:7: multiple definition of `findroll(int, int, int)'; /tmp/ccFhCWEu.o:/home/calculations.c:7: first defined here
/usr/bin/ld: /tmp/cc3PaZfu.o: in function `dodamage(int, int, int, int)':
/home/calculations.c:19: multiple definition of `dodamage(int, int, int, int)'; /tmp/ccFhCWEu.o:/home/calculations.c:19: first defined here
collect2: error: ld returned 1 exit status
I can't find where the multiple definitions are and it is driving me up a wall. The calculations worked fine before I put it in it's own page.