основная программа вызывает оба, readinputdata считывает строку и writeoutputdata выписывает это. Данные считываются в строковый мусор, который определен в пространстве имен «INPUTDATA», присутствующем в INPUT.h, а функции объявлены в «FUNCTIONS.h».
Я получаю следующую ошибку:
Код: Выделить всё
g++ -o f2d ../obj/main_program.o ../obj/read_input_data.o ../obj/write_output_data.o -Wall -Wextra -O3 -Werror -pedantic -Ofast
/usr/bin/ld: ../obj/read_input_data.o:(.bss+0x0): multiple definition of `INPUTDATA::garbage[abi:cxx11]'; ../obj/main_program.o:(.bss+0x0): first defined here
/usr/bin/ld: ../obj/write_output_data.o:(.bss+0x0): multiple definition of `INPUTDATA::garbage[abi:cxx11]'; ../obj/main_program.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: f2d] Error 1
main_program.cpp
Код: Выделить всё
// main_program.cpp
// libraries to include
#include
#include
#include //Wheres Wallace????
// header files
#include "../headers/INPUT.h"
#include "../headers/FUNCTIONS.h"
using namespace INPUTDATA;
using namespace std;
int main()
{
read_input_data();
write_output_data();
return 0;
}
Код: Выделить всё
#include
#include //Wheres Wallace????
#include "../headers/INPUT.h"
#include "../headers/FUNCTIONS.h"
using namespace std;
using namespace INPUTDATA;
void read_input_data()
{
cin>>garbage;
}
Код: Выделить всё
#include
#include //Wheres Wallace????
#include "../headers/INPUT.h"
#include "../headers/FUNCTIONS.h"
using namespace std;
using namespace INPUTDATA;
void write_output_data()
{
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/78422015/hi-i-am-getting-multiple-definitions-of-first-defined-here-error[/url]