Skip to content

[cxx-interop] constexpr from within a namespace is not available in Swift #81327

Open
@Drejzer

Description

@Drejzer

Description

When a constexpr is declared inside a namespace, it won't be visible from Swift; but declaring it in the global namespace will make it visible in Swift.

Reproduction

In a cpp target:

namespace namespace_test{
constexpr int TEST1 = 44;
static constexpr char TEST2 = 't';
}
constexpr int TEST1 = 44;
static constexpr char TEST2= 't';

And then in swift

import cxx_target

let i = TEST1
let i2 - namespace_test.TEST1

let c = TEST2
let c2 = namespace_test.TEST2

which will result in "error: type 'namespace_test' has no member 'TEST1'" and "error: type 'namespace_test' has no member 'TEST2'"

Expected behavior

The constexprs are available in Swift.

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions