Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. CONote that whether it indeed compiles *and links* without error depends on the toolchain. In particular, Microsoft's toolchain will by default not link it for the most common kind of Windows executable, a "GUI subsystem" executable. For that, one must use the not well-documented linker option `/entry:mainCRTStartup`.
      singulars
    2. COThe OP asked about compilation only, not linking. Regardless, C++ requires `main()` to be declared with external linkage, so if Microsoft's linker can't process such a simple translation unit without throwing an error, then I suspect it's either not operating in a standards-compliant mode, or else the C++ standard permits linkers to impose additional restrictions on translation units (in which case _no one_ can provide a program which is guaranteed to link on any conforming toolchain).
      singulars
    3. COLet me first address a simple error in your answer. The last paragraph that the return value can be omitted for `main`, is incorrect. If there is a `return`, then it must specify a return value (since the function is declared with one), and conversely, if you *meant* that a `return` can only be omitted without UB for `main`, well, it must be omitted for `noreturn` functions. The OP's wording commonly means compilation + linking, and that's the only interpretation that makes sense. Microsoft's linker (and their compiler) is *non-standard* by default.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload