mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Fixes to examples and MSVC compilation.
This commit is contained in:
committed by
Christoffer Lerno
parent
cc5f9c6aab
commit
8bb99c6f81
@@ -47,7 +47,7 @@ fn Resource! prep_out(String out_name, String[] prep_names)
|
||||
|
||||
fn void main()
|
||||
{
|
||||
Resource writer = prep_out("out", String[] { "a", "b"})!!;
|
||||
Resource writer = prep_out("out", (String[]) { "a", "b"})!!;
|
||||
defer writer.deinit();
|
||||
io::printn("use out");
|
||||
}
|
||||
@@ -27,6 +27,6 @@ fn void main()
|
||||
{
|
||||
long val1 = perform("something");
|
||||
long val2 = @with_mode("faster", perform, "reliable");
|
||||
long val3 = perform(String[] {"something"});
|
||||
long val3 = perform((String[]){"something"});
|
||||
io::printfn("%d %d %d", val1, val2, val3);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ int err_count = 0;
|
||||
fn int! ask_guess(int high)
|
||||
{
|
||||
io::printf("Guess a number between 1 and %d: ", high);
|
||||
String text = io::readline() ?? InputResult.FAILED_TO_READ?!;
|
||||
String text = io::treadline() ?? InputResult.FAILED_TO_READ?!;
|
||||
return text.to_int() ?? InputResult.NOT_AN_INT?;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ import std::io;
|
||||
|
||||
fn void main()
|
||||
{
|
||||
Path path = path::new_cwd()!!;
|
||||
foreach (i, p : path::new_ls(path)!!)
|
||||
Path path = path::cwd(mem)!!;
|
||||
foreach (i, p : path::ls(mem, path)!!)
|
||||
{
|
||||
io::printfn("%02d %s", i, p.str_view());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ fn void main()
|
||||
{
|
||||
printn("Enter a story template, terminated by an empty line:");
|
||||
String story = "";
|
||||
while (try String line = stdin().readline().strip())
|
||||
while (try String line = stdin().readline(mem).strip())
|
||||
{
|
||||
|
||||
story = story.append(line);
|
||||
@@ -21,7 +21,7 @@ fn void main()
|
||||
{
|
||||
VarString s = match.string;
|
||||
printf("Enter a value for '%s': ", s[1..^2]);
|
||||
String word = stdin().readline().strip()!;
|
||||
String word = stdin().readline(mem).strip()!;
|
||||
story = story.replace(s, word);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ fault TokenResult
|
||||
fn void main(String[] args)
|
||||
{
|
||||
// Grab a string from stdin
|
||||
String s = io::readline()!!;
|
||||
String s = io::readline(mem)!!;
|
||||
// Delete it at scope end [defer]
|
||||
defer s.free();
|
||||
defer free(s);
|
||||
|
||||
// Copy the slice, which doesn't change the underlying data.
|
||||
String numbers = s;
|
||||
|
||||
@@ -40,7 +40,7 @@ const char *manifest_target_keys[][2] = {
|
||||
|
||||
const int manifest_target_keys_count = ELEMENTLEN(manifest_target_keys);
|
||||
|
||||
const char *manifest_deprecated_target_keys[] = { };
|
||||
const char *manifest_deprecated_target_keys[] = { "none" };
|
||||
|
||||
const int manifest_deprecated_target_key_count = ELEMENTLEN(manifest_deprecated_target_keys);
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ enum Foo : char
|
||||
distinct Abc = int;
|
||||
fn void main()
|
||||
{
|
||||
$assert (Foo.ABC - Foo.BCD) == 255;
|
||||
char c = Foo.ABC - Foo.BCD;
|
||||
$assert $typeof(Foo.ABC - Foo.BCD).typeid == char.typeid;
|
||||
$assert Foo.BCD - 1 == Foo.ABC;
|
||||
$assert Foo.ABC + 1 == Foo.BCD;
|
||||
$assert $typeof(Foo.BCD - 1).typeid == Foo.typeid;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import std;
|
||||
|
||||
def IList = List{int};
|
||||
fn IList new()
|
||||
fn IList IList.newAbc(&self)
|
||||
{
|
||||
IList l;
|
||||
l.init(mem, $vasplat); // #error: can only be used inside
|
||||
@@ -11,8 +11,9 @@ fn IList new()
|
||||
|
||||
fn void main()
|
||||
{
|
||||
IList a = new(123, 123, 123, 123, 123, 123, 123, 134);
|
||||
IList x;
|
||||
IList a = x.newAbc(123, 123, 123, 123, 123, 123, 123, 134);
|
||||
a.push(567);
|
||||
|
||||
io::printfn("%s", a[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user