[libc-commits] [libc] [libc] Fix warning on 'extern "C" int main' in test suite (PR #102973)

via libc-commits libc-commits at lists.llvm.org
Mon Aug 12 15:46:07 PDT 2024


================
@@ -43,7 +43,15 @@ TestOptions parseOptions(int argc, char **argv) {
 
 } // anonymous namespace
 
-extern "C" int main(int argc, char **argv, char **envp) {
+// The C++ standard forbids declaring the main function with a linkage specifier
+// outisde of 'freestanding' mode, only define the linkage for hermetic tests.
+#ifdef __STDC_HOSTED__
----------------
lntue wrote:

Do you need to explicitly check if it's not 0?
```
$ diff <(clang++ -dM -E - < /dev/null) <(clang++ -dM -E -ffreestanding - < /dev/null)
86d85
< #define __GCC_HAVE_DWARF2_CFI_ASM 1
243c242
< #define __STDC_HOSTED__ 1
---
> #define __STDC_HOSTED__ 0
```


https://github.com/llvm/llvm-project/pull/102973


More information about the libc-commits mailing list