redefinition

Re-definitions of functions while including files in C++ (error LNK2005)

我的梦境 提交于 2021-02-05 08:28:07
问题 I'm new to C++ and I have a basic doubt. I'm creating a french verb conjugating application. I have two files, a Conjugator.cpp file and an ErVerbs.cpp file. I want to keep the bulk of my functions in the ErVerbs source file and use the conjugator file to use these functions. Here are a few code snippets: Conjugator.cpp #include <iostream> #include <string> #include "Variables.h" #include "ErVerbs.cpp" #include "IrVerbs.cpp" #include "ReVerbs.cpp" using namespace std; void check() { if (verb

GCC does not complain about re-definition of external variable? [duplicate]

我的梦境 提交于 2021-01-27 07:20:33
问题 This question already has answers here : About Tentative definition (2 answers) Closed 3 years ago . This simple code (MCVE): #include <stdio.h> int a = 3; int main(){ printf("%d\n", a); return 0; } int a; // This line To my surprise, GCC (MinGW GCC 4.8.2, 4.9.2 and 6.3.0) does not give any error, not even warnings about the marked line! However it does if I assign a value to a at its second definition. More strangely, g++ tells me that the second re-definition is an error, but gcc doesn't.

GCC does not complain about re-definition of external variable? [duplicate]

偶尔善良 提交于 2021-01-27 07:17:05
问题 This question already has answers here : About Tentative definition (2 answers) Closed 3 years ago . This simple code (MCVE): #include <stdio.h> int a = 3; int main(){ printf("%d\n", a); return 0; } int a; // This line To my surprise, GCC (MinGW GCC 4.8.2, 4.9.2 and 6.3.0) does not give any error, not even warnings about the marked line! However it does if I assign a value to a at its second definition. More strangely, g++ tells me that the second re-definition is an error, but gcc doesn't.

GCC does not complain about re-definition of external variable? [duplicate]

半世苍凉 提交于 2021-01-27 07:15:40
问题 This question already has answers here : About Tentative definition (2 answers) Closed 3 years ago . This simple code (MCVE): #include <stdio.h> int a = 3; int main(){ printf("%d\n", a); return 0; } int a; // This line To my surprise, GCC (MinGW GCC 4.8.2, 4.9.2 and 6.3.0) does not give any error, not even warnings about the marked line! However it does if I assign a value to a at its second definition. More strangely, g++ tells me that the second re-definition is an error, but gcc doesn't.

redefinition of template<class T> in C++

前提是你 提交于 2021-01-27 04:18:31
问题 I have searched and searched for a solution to my problem but I cannot seem to find one. I am using Code::Blocks and I am getting a redefinition error of a template class. Here is my "vectorAux.h" file: #ifndef vectoraux_h #define vectoraux_h #include <vector> #include <algorithm> #include <iostream> template <typename T> void removeDup(std::vector<T> & v); template <typename T> unsigned seqVectSearch(const std::vector<T> & v, unsigned first, unsigned last, const T& target); template

Error: Redefinition of Class (C++)

为君一笑 提交于 2020-06-23 13:17:09
问题 I'm trying to figure out why I'm getting the following error: error: redefinition of 'TimeDuration' // TimeDuration.cpp #define HOUR 3600 #define MIN 60 #include <iostream> #include <string> #include "TimeDuration.h" using namespace std; TimeDuration::TimeDuration() { seconds = 0; } void TimeDuration::setDuration(const int sec) { seconds = sec; } void TimeDuration::display() { // Some code to display the time } The error is showing in my header file. // TimeDuration.h class TimeDuration {

Error: Redefinition of Class (C++)

核能气质少年 提交于 2020-06-23 13:17:06
问题 I'm trying to figure out why I'm getting the following error: error: redefinition of 'TimeDuration' // TimeDuration.cpp #define HOUR 3600 #define MIN 60 #include <iostream> #include <string> #include "TimeDuration.h" using namespace std; TimeDuration::TimeDuration() { seconds = 0; } void TimeDuration::setDuration(const int sec) { seconds = sec; } void TimeDuration::display() { // Some code to display the time } The error is showing in my header file. // TimeDuration.h class TimeDuration {

multiple definition: error at link time

陌路散爱 提交于 2020-06-09 06:10:12
问题 I'm writing a couple of classes for an exercise on copy control members in the C++ primer book. I put the classes definitions in their respective header files,and implementation in code files. I seem to have done all things like they should be done, but I get an error at link time I can't understand (and I already spent half an hour thinking about it) here's the message class (headers and code files) message.h #include <string> #include "folder.h" class message { friend void swap(message&

multiple definition: error at link time

十年热恋 提交于 2020-06-09 06:10:04
问题 I'm writing a couple of classes for an exercise on copy control members in the C++ primer book. I put the classes definitions in their respective header files,and implementation in code files. I seem to have done all things like they should be done, but I get an error at link time I can't understand (and I already spent half an hour thinking about it) here's the message class (headers and code files) message.h #include <string> #include "folder.h" class message { friend void swap(message&

error C2375: redefinition; different linkage

一笑奈何 提交于 2020-02-23 11:09:38
问题 Error place in api: #define DLLEXPORT extern "C" __declspec(dllexport) DLLEXPORT int CAnyseeUSBTVControllerDlg::InitCaptureDevice() { In my .h library class and function definition: class CAnyseeUSBTVControllerDlg : public CDialog { // Construction public: int InitCaptureDevice(void); Any idea how to resolve it? "Error 1 error C2375: 'CAnyseeUSBTVControllerDlg::InitCaptureDevice' : redefinition; different linkage c:\Program Files\toATS_DVS\anysee\anyseee30\anyseee30\anyseeUSBTVControllerDlg