ncihnegn / miranda

Miranda is a pure, non-strict, polymorphic, higher order functional programming language designed by David Turner in 1983-6. https://codesync.global/media/open-sourcing-miranda-david-turner-code-mesh-v-2020-codemeshv2020/
http://miranda.org.uk
Other
53 stars 8 forks source link

Problems building #3

Open sebastian-davidson opened 1 week ago

sebastian-davidson commented 1 week ago

I tried compiling this program at first just by running make. The Makefile failed to compile it, because GCC said there was a problem in the HOST macro:

<command-line>: error: ‘compiled’ undeclared here (not in a function)
version.c:3:12: note: in expansion of macro ‘HOST’
    3 | char *host=HOST;
      |            ^~~~
<command-line>: error: expected ‘,’ or ‘;’ before ‘:’ token
version.c:3:12: note: in expansion of macro ‘HOST’
    3 | char *host=HOST;
      |            ^~~~
<command-line>: error: stray ‘\’ in program
version.c:3:12: note: in expansion of macro ‘HOST’
    3 | char *host=HOST;
      |            ^~~~
<command-line>: error: stray ‘\’ in program
version.c:3:12: note: in expansion of macro ‘HOST’
    3 | char *host=HOST;
      |            ^~~~

I changed the flag to -DHOST="\"$(shell cat .host)\"" instead, and then that error went away. So, I tried again.

However, then I ran into a long list of linker errors (which I won't list unless you ask), entirely consisting of multiple definitions of global variables: hd, tl, files, current_file, tag, buf, and commandmode.

Am I doing something wrong when compiling, or does this program need to be updated so as not to have multiple definitions?

ncihnegn commented 1 week ago

Try the cmake build please.

sebastian-davidson commented 1 week ago

Okay, so now I've done this:

$ mkdir build
$ cmake -G "Unix Makefiles" -S . -B build
$ cd build
$ make

It fails to build due to what looks like two errors in the file reduce.c:

[  6%] Building C object CMakeFiles/just.dir/just.c.o
[ 13%] Linking C executable just
[ 13%] Built target just
[ 20%] Building C object CMakeFiles/menudriver.dir/menudriver.c.o
[ 26%] Linking C executable miralib/menudriver
[ 26%] Built target menudriver
[ 33%] Building C object CMakeFiles/mira.dir/big.c.o
[ 40%] Building C object CMakeFiles/mira.dir/cmbnms.c.o
[ 46%] Building C object CMakeFiles/mira.dir/data.c.o
[ 53%] Building C object CMakeFiles/mira.dir/lex.c.o
[ 60%] Building C object CMakeFiles/mira.dir/reduce.c.o
/home/sebastian/Build/miranda/reduce.c: In function ‘outf’:
/home/sebastian/Build/miranda/reduce.c:260:15: error: implicit declaration of function ‘fileno’; did you mean ‘fileinfo’? [-Wimplicit-function-declaration]
  260 |     if(isatty(fileno(s_out)))setbuf(s_out,NULL); /*for unbuffered tty output*/
      |               ^~~~~~
      |               fileinfo
/home/sebastian/Build/miranda/reduce.c: In function ‘reduce’:
/home/sebastian/Build/miranda/reduce.c:1716:24: error: implicit declaration of function ‘fdopen’; did you mean ‘fopen’? [-Wimplicit-function-declaration]
 1716 |             fp=(FILE *)fdopen(fd[0],"r"),
      |                        ^~~~~~
      |                        fopen
/home/sebastian/Build/miranda/reduce.c:1716:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
 1716 |             fp=(FILE *)fdopen(fd[0],"r"),
      |                ^
/home/sebastian/Build/miranda/reduce.c:1717:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
 1717 |             fp_a=(FILE *)fdopen(fd_a[0],"r");
      |                  ^
make[2]: *** [CMakeFiles/mira.dir/build.make:132: CMakeFiles/mira.dir/reduce.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/mira.dir/all] Error 2
make: *** [Makefile:91: all] Error 2