[cfe-dev] clang++ and g++ difference. Who is right ?
Jean-Daniel Dupas
devlists at shadowlab.org
Wed Jul 7 00:52:25 PDT 2010
Sorry for the previous incomplete post,
I know there is come C++ expert around, so maybe someone may tell me who is right and who is wrong compiling the following code:
---------------- extern.cpp ---------------
#include <stdio.h>
namespace lldb_private { const char *GetVersion(); }
const char * lldb_private::GetVersion() {
extern const double LLDBVersionNumber;
static char g_version_string[32];
if (g_version_string[0] == '\0')
::snprintf (g_version_string, sizeof(g_version_string), "LLDB-%g", LLDBVersionNumber);
return g_version_string;
}
-------------------------------------------
clang++ mangle the external reference to LLDBVersionNumber using c++ rules => __ZN12lldb_private17LLDBVersionNumberE
but g++ uses C rules => _LLDBVersionNumber
As a side note, if you move the GetVersion() implementation inside the namespace body, both compilers use C++ mangling.
-- Jean-Daniel
-- Jean-Daniel
More information about the cfe-dev
mailing list