From a9d93c93d519da58abc0407d6899174af85119ce Mon Sep 17 00:00:00 2001 From: Kiana Date: Sat, 31 Jan 2026 04:55:47 +0100 Subject: [PATCH] Improve linker error message (#2880) * Improve linker error message * use file_util/file_is_dir instead * cleanup unused function * Some minor updates and merging latest master. --------- Co-authored-by: Christoffer Lerno --- releasenotes.md | 1 + src/compiler/linker.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/releasenotes.md b/releasenotes.md index 110385f16..749fd46a6 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -7,6 +7,7 @@ ### Stdlib changes ### Fixes +- Add error message if directory with output file name already exists ## 0.7.9 Change list diff --git a/src/compiler/linker.c b/src/compiler/linker.c index cc5779b9b..32dc1eada 100644 --- a/src/compiler/linker.c +++ b/src/compiler/linker.c @@ -1051,6 +1051,11 @@ void platform_linker(const char *output_file, const char **files, unsigned file_ vec_add(parts, compiler.build.cc ? compiler.build.cc : default_c_compiler()); } + if (file_is_dir(output_file)) + { + error_exit("Failed to link executable '%s', a directory with that name already exists.", output_file); + } + linker_setup(&parts, files, file_count, output_file, linker_type, &compiler.linking); const char *output = assemble_linker_command(parts, PLATFORM_WINDOWS); if (compiler.build.print_linking) puts(output);