Skip to content

Compile errors with clang on Windows #40

@nickhutchinson

Description

@nickhutchinson

When building with clang on Windows using nssv_CONFIG_SELECT_STRING_VIEW=nssv_STRING_VIEW_NONSTD, you can get compilation errors due to multiple functions defined by string-view-lite mapping to the same mangled symbol name.

This does not occur when building with MSVC, because in that case string-view-lite ensures that the operator== functions have different signatures (see nssv_MSVC_ORDER).

$ cat >test.cpp <<EOF
#include "nonstd/string_view.hpp"
// Ensure both operator== functions are instantiated
int foo() { return "" == nonstd::string_view(""); }
int bar() { return nonstd::string_view("") == ""; }
EOF

$  clang-cl -Dnssv_CONFIG_SELECT_STRING_VIEW=nssv_STRING_VIEW_NONSTD -Fotest.obj -c test.cpp
In file included from test.cpp:1:
nonstd/string_view.hpp(1274,21): error: definition with same mangled name
      '??$?8DU?$char_traits@D@std@@@sv_lite@nonstd@@YA_NV?$basic_string_view@DU?$char_traits@D@std@@@01@0@Z' as another definition
nssv_constexpr bool operator==(
                    ^
nonstd/string_view.hpp(1280,21): note: previous definition is here
nssv_constexpr bool operator==(
                    ^
1 error generated.

Tested under clang 11.0.1, MSVC 2019 19.28, string-view-lite 1.6.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions