[MLton-devel] z.c & y.c

Matthew Fluet fluet@CS.Cornell.EDU
Thu, 12 Sep 2002 07:57:54 -0400 (EDT)


> Your (Matthew) proported compilation of these programs clearly can't be right
> since they would not link (they don't define main unless you include more
> of MLton stuff).  What EXACTLY did you do to compile y.c and z.c to try run
> them.  Also where is z.h, included in y.c?

z.c is just the MLton_init function, z.h is the declaration of MLton_init,
and y.c has main.

To compile, I just compiled z.c to an object file on a 7.3 box with -O1.
And I compiled y.c to an executable, linking with z.o, on a 7.1 box with -O1.

z.h looks like:
int MLton_init(int, char**);

z.c looks like:
#include <string.h>
#include <stdio.h>

int MLton_init(int argc, char** argv) {
  int i;
  printf("MLton_init:\n");
  printf("argc = %i\n", argc);

  i = 1;
  if (argc > 1 && (0 == strcmp (argv [1], "@MLton"))) {
    int done;

    /* process @MLton args */
    i = 2;
    done = 0;
    while (!done) {
      if (i == argc) {
        printf("i == argc\n");
        return i;
      } else {
        char* arg;

        arg = argv[i];
        printf("argv[%i] = %s\n", i, argv[i]);
        if (0 == strcmp (arg, "gc-summary")) {
          ++i;
        } else if (0 == strcmp (arg, "--")) {
          ++i;
          done = 1;
        } else if (i > 1) {
          printf ("i > 1\n");
          return i;
        } else done = 1;
      }
    }
  }
  return i;
}

y.c looks like:
#include "z.h"
#include <stdio.h>

int main(int argc, char** argv) {
  int i, start;
  start = MLton_init(argc, argv);
  printf("Main:\n");
  for (i = start; i < argc; i++)
    printf("argv[%i] = %s\n", i, argv[i]);
  return 1;
}





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel