arun11299 / cpp-subprocess

Subprocessing with modern C++
Other
456 stars 90 forks source link

Multiple definition Error #34

Open CarlyAmar opened 5 years ago

CarlyAmar commented 5 years ago

My code is set up as follows:

main.h

#include "helper.h"

helper.h

#include "subprocess.hpp"

helper.cpp

#include "helper.h"

Error:


Because of this, I get:

main.cpp.o: In function std::iterator_traits<unsigned char const*>::iterator_category std::__iterator_category<unsigned char const*>(unsigned char const* const&)': subprocess.hpp:152: multiple definition ofsubprocess::util::quote_argument(std::basic_string<wchar_t, std::char_traits, std::allocator > const&, std::basic_string<wchar_t, std::char_traits, std::allocator >&, bool)' main.cpp.o:/subprocess.hpp:152: first defined here helper.cpp.o: In function std::vector<char*, std::allocator<char*> >::reserve(unsigned int)': /subprocess.hpp:152: multiple definition ofsubprocess::util::quote_argument(std::basic_string<wchar_t, std::char_traits, std::allocator > const&, std::basic_string<wchar_t, std::char_traits, std::allocator >&, bool)' main.cpp.o:/subprocess.hpp:152: first defined here collect2: error: ld returned 1 exit status

Solution


This is easily solved by changing void quote_argument(const std::wstring &argument, std::wstring &command_line, bool force) to inline void quote_argument(const std::wstring &argument, std::wstring &command_line, bool force)

* Filenames changed for privacy.