Skip to content

[Clang] Diagnose extern "C++" int main() #101512

Closed
@MitalAshok

Description

@MitalAshok

This currently just seems to be ignored (the name is not mangled).
It is explicitly disallowed by https://eel.is/c++draft/basic.start.main#3.sentence-5

The main function shall not be declared with a linkage-specification.

This includes

extern "C++" { int main(); }

This is also technically ill-formed

extern "C" int main();

but it seems to be used in some places:

extern "C" int main(int argc, char **argv, char **envp);

extern "C" int main(int argc, char **argv, char **envp);

So this should probably just be a warning, not an error.

Metadata

Metadata

Assignees

Labels

c++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"good first issuehttps://github.com/llvm/llvm-project/contribute

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions