Skip to content

What signatures are acceptable for Run? How are argc and argv exposed? #6735

@zygoloid

Description

@zygoloid

Summary of issue:

We need to somehow expose command-line arguments to Carbon programs. So far the toolchain permits fn Run() and fn Run -> i32, with no support for arguments. But even that is not covered by any proposal I can find.

Details:

#2550 established that the entry point is named Run in the Main package, but did not specify what signatures it can have.

Any other information that you want to share?

C++ allows:

int main();
int main() noexcept;
int main(int, char**);
int main(int, char**) noexcept;

Implementations often also allow the return type to be declared as void, and some allow a third char** envp parameter.

Some platforms have their own convention, such as WinMain on Windows.

The toolchain allows the return type to be omitted. When this happens, the return value is currently uninitialized, rather than being set to 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    examples-2026An issue that is relevant for examples we are trying to port to Carbon in 2026.leads questionA question for the leads team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions