hello_world.carbon 1019 B

123456789101112131415161718192021222324252627282930313233
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. import Cpp inline "#include <cstdio>";
  5. fn Run() {
  6. // TODO: Requires member operator << and class with virtual bases
  7. // (basic_ostream).
  8. // Cpp.std.cout << "Hello world!\n";
  9. // TODO: Requires variadic function.
  10. // Cpp.printf("Hello world!\n");
  11. // TODO: Requires nullable pointer.
  12. // Cpp.puts("Hello world!\n");
  13. // TODO: Requires nullable void pointer.
  14. // Cpp.write(1, "Hello world!\n", 13);
  15. // TODO: Requires Core.String API.
  16. // let message: str = "Hello world!\n\n";
  17. // for (c: Core.Char in message) {
  18. // Cpp.putchar((c as u8) as i32);
  19. // }
  20. let message: array(Core.Char, 13) =
  21. ('H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', '\n');
  22. for (c: Core.Char in message) {
  23. // TODO: u8 should probably have an implicit cast to i32.
  24. Cpp.putchar((c as u8) as i32);
  25. }
  26. }