Skip to content

[C++20][Modules] Cannot export a declaration within a linkage-specification #71347

@cpplearner

Description

@cpplearner

Clang rejects the following module unit:

export module mod;

extern "C++" {
    export void f();
}

(https://godbolt.org/z/dPYhGW7ah)

The error message is:

<source>:4:5: error: export declaration can only be used within a module purview
    4 |     export void f();
      |     ^

I think the declaration of f should be considered to be within the purview of module mod, even though it is attached to the global module.

Note that GCC and MSVC accept the above module unit.

Also note that clang seems to permit export extern "C++" { void f(); }.

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header Modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions