mercredi 1 janvier 2020

c++ 'defined in both module' error for global functions (only happens in 64 bit mode) [closed]

I'm using Embarcadeo c++ Builder 10.2. When I compile in 32 bit mode (debug or release) I get no errors. In 64 bit mode I get 372 'defined in both module' errors each relating to a global inline function I've declared in globals.h.

From the thread C++: Multiple definition error for global functions in the header file I find that preceding the declaration with inline removes the errors but was wondering if anyone can cast any light on why it only happens with 64 bit compiles. I'm using the built in clang compiler for both 32 bit & 64 bit compiles.

minimal example

file Dummy.h

#ifndef DummyH
#define DummyH
//---------------------------------------------------------------------------
void x() {};
#endif

added

#include "Dummy.h"

to globals.h

In 32 bit mode I get no error but in 64 bit mode I get "symbol x() defined in both module …..". Redeclaring x() as

inline void x() {}; 

removes the error in 64 bit mode.

Aucun commentaire:

Enregistrer un commentaire