From 803b680a03c9513cf71549bb7545d72606cbe337 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Thu, 13 Jul 2023 15:29:31 +0200 Subject: [PATCH] See if we can find out where the bug is. --- .github/workflows/main.yml | 15 --------------- lib/std/io/os/file_libc.c3 | 4 +++- resources/examples/load_world.c3 | 32 ++++++++++++++++++++++++++------ src/compiler/target.c | 2 +- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f4a5cac7..6b5f89615 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,13 +33,7 @@ jobs: - name: Compile and run some examples run: | cd resources - ..\build\${{ matrix.build_type }}\c3c.exe compile-run examples\hello_world_many.c3 - ..\build\${{ matrix.build_type }}\c3c.exe compile-run examples\time.c3 - ..\build\${{ matrix.build_type }}\c3c.exe compile-run examples\fannkuch-redux.c3 - ..\build\${{ matrix.build_type }}\c3c.exe compile-run examples\contextfree\boolerr.c3 - ..\build\${{ matrix.build_type }}\c3c.exe compile-run examples\ls.c3 ..\build\${{ matrix.build_type }}\c3c.exe compile-run examples\load_world.c3 - ..\build\${{ matrix.build_type }}\c3c.exe compile-run examples\process.c3 - name: Build testproject @@ -103,11 +97,6 @@ jobs: - name: Compile and run some examples run: | cd resources - ../build/c3c compile-run examples/hello_world_many.c3 - ../build/c3c compile-run examples/time.c3 - ../build/c3c compile-run examples/fannkuch-redux.c3 - ../build/c3c compile-run examples/contextfree/boolerr.c3 - ../build/c3c compile-run examples/load_world.c3 ../build/c3c compile-run examples/load_world.c3 - name: Build testproject @@ -159,10 +148,6 @@ jobs: - name: Compile and run some examples run: | cd resources - ../build/c3c compile-run examples/hello_world_many.c3 - ../build/c3c compile-run examples/time.c3 - ../build/c3c compile-run examples/fannkuch-redux.c3 - ../build/c3c compile-run examples/contextfree/boolerr.c3 ../build/c3c compile-run examples/load_world.c3 - name: Build testproject diff --git a/lib/std/io/os/file_libc.c3 b/lib/std/io/os/file_libc.c3 index 2a9abbfe8..2361111c3 100644 --- a/lib/std/io/os/file_libc.c3 +++ b/lib/std/io/os/file_libc.c3 @@ -7,6 +7,7 @@ import libc; **/ fn void*! native_fopen(String filename, String mode) @inline { + libc::printf("Got here\n"); @pool() { $if env::WIN32: @@ -14,7 +15,8 @@ fn void*! native_fopen(String filename, String mode) @inline $else void* file = libc::fopen(filename.zstr_tcopy(), mode.zstr_tcopy()); $endif - return file ?: file_open_errno()?; + libc::printf("Got herfffe\n"); + return file ?: IoError.FILE_NOT_FOUND?; }; } diff --git a/resources/examples/load_world.c3 b/resources/examples/load_world.c3 index 9c87b23aa..627cb58bd 100644 --- a/resources/examples/load_world.c3 +++ b/resources/examples/load_world.c3 @@ -1,11 +1,31 @@ module load_world; import std::io; +import libc; fn void! main() { - File f = file::open("examples/hello_world.txt", "rb")!; - defer f.close()!!; - while (!f.eof()) + native_fopen2("examples/hello_world.txt", "rb")!; +} + +int a; + +fn int* test() +{ + return &a; +} +/** + * @require mode.len > 0 + * @require filename.len > 0 + **/ +fn void*! native_fopen2(String filename, String mode) +{ + @pool() { - @pool() { io::printn(f.tgetline()); }; - } -} \ No newline at end of file + $if env::WIN32: + + void* file = test(); + $else + void* file = libc::fopen(filename.zstr_tcopy(), mode.zstr_tcopy()); + $endif + return null; + }; +} diff --git a/src/compiler/target.c b/src/compiler/target.c index 70d0b03b1..09f82a240 100644 --- a/src/compiler/target.c +++ b/src/compiler/target.c @@ -1769,7 +1769,7 @@ void target_setup(BuildTarget *target) { if (platform_target.os == OS_TYPE_WIN32) { - target->debug_info = DEBUG_INFO_NONE; + target->debug_info = DEBUG_INFO_FULL; } else {