Hacker News new | ask | show | jobs
by kazinator 697 days ago
This is not useful if it doesn't call external libraries.

Even POSIX standard ones. Chokes on:

  #include <glob.h>

  int main()  // must be (); (void) results in syntax error.
  {
    glob_t gb; // syntax error here
    glob("abc", 0, NULL, &gb);
    return 0;
  }
Nobody needs entirely self-contained C programs with no libraries to be turned into shell scripts; Unix people switch to C when there is a library function they need to call for which there no command in /bin or /usr/bin.

If I reduce it to:

  #include <glob.h>

  int main()
  {
    glob("abc", 0, NULL, 0);
    return 0;
  }
it "compiles" into something with a main function like:

  _main() {
    defstr __str_0 "abc"
    _glob __ $__str_0 0 $_NULL 0
    : $(($1 = 0))
  }
but what good is that without a definition of _glob.