Skip to content

gcc ld invalid argument error, when appending "" to cmd #130

@whophi

Description

@whophi

System:

  • Windows 11 (10.0-26100)
  • MINGW64_NT-10.0-26100 version 3.6.4-23a25d49.x86_64 (runneradmin@runnervm51nrn) (gcc version 15.1.0 (GCC) )
  • Nob.h - v1.23.0

Minimal example:

// File: nob_test.c
#define NOB_IMPLEMENTATION
#include "nob.h"
int main(int argc, char** argv)
{
  NOB_GO_REBUILD_URSELF(argc, argv);
  Nob_Cmd cmd = {0};
  nob_cmd_append(&cmd, "gcc", "-o", "bug_test", __FILE__, ""); // No error, when removing the "" here
  if (!nob_cmd_run(&cmd)) return 1;
  return 0;
}
gcc -o nob_test nob_test.c
./nob_test.exe

Output:

[INFO] CMD: gcc -o bug_test ./nob_test.c 
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find : Invalid argument
collect2.exe: error: ld returned 1 exit status
[ERROR] command exited with exit code 1

This is useful for macros, e.g.:

# define ASSERT_ENABLE ""
# define ASSERT_DISABLE "-DNDEBUG"

NOTE: This worked in v1.20.2, using the old api (nob_cmd_run_sync_and_reset)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions