Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 2 months ago.
The compiler displays Error 247 but I don't know why
Hi everyone!
I'm currently working on a program for a school project and the compiler displays an error 247 (variable or function already define) for several objects, but I can't find where the multiples definitions are from. Perhaps somebody can help me :)
Here's my code (so far) :
This file contains my functions
#include "mbed.h" #include "options.h" DigitalIn freq1(p8); Timer timer; float compteur() { float T=0; if(freq1==1) { timer.start(); if(freq1==1) { T = timer.read(); } } wait(1); timer.stop(); timer.reset(); return T; } float frequence(float periode) { int f; f = (1/periode); return f; } int receive(Serial pc) { int data[5]; pc.scanf("%d", data); pc.printf("%d", data); return 0; } int transmit(int retour) { int n=11; int a; int c = 0 ; while( n >= 1 ) { a = n % 2; if ( a == 1 ) { c = c + 1; } n = n / 2; } return 0; }
This one is the main
#include "mbed.h" #include "options.h" Serial in(p9, p10); Serial pc(USBTX, USBRX); Serial out(p13, p14); int main() { pc.format(7, Serial::Even, 1); pc.baud(9600); in.format(7, Serial::Even, 1); in.baud(9600); out.format(8, Serial::Even, 1); out.baud(9600); }
And finally this one is my header file
#ifndef OPTIONS_H_INCLUDED #define OPTIONS_H_INCLUDED #include "mbed.h" #include "compt.cpp" float frequence(float); int receive(Serial); #endif
1 Answer
6 years, 1 month ago.
Hi Victor,
For which target/board are you trying to compile for? Also, in your last header file, on line 5 #include "compt.cpp"
that code is going to essentially copy all of the contents from your compt.cpp file into your header file, which may be causing the multiple definitions.
- Jenny, team Mbed