Terraspace / UASM

UASM - Macro Assembler
http://www.terraspace.co.uk/uasm.html
Other
221 stars 49 forks source link

Compillation problem, missing '-fwritable-strings' #211

Open Fojtik opened 3 months ago

Fojtik commented 3 months ago

I would recommend to use autoconf and configure script. Configure script could check all command line optional options.

Option "-fwritable-strings" is not supported from GCC4.

Please note that I have most of these issues solved in my free of charge program https://ftsoft.com.cz/wp2latex/wp2latex.htm I can help you to fix it.

JFT@DESKTOP-E4MGIUU MINGW32 /o/src/uasm
$ make -f Makefile_LinuxGCC
g++ -D __UNIX__ -c -IH -D __UNIX__ -DNDEBUG -O2 -ansi -funsigned-char -fwritable-strings -o GccUnixR/main.o main.c
g++.exe: error: unrecognized command-line option '-fwritable-strings'; did you mean '-Wwrite-strings'?
make: *** [Makefile_LinuxGCC:34: GccUnixR/main.o] Error 1

after removing this option I see another error:

JFT@DESKTOP-E4MGIUU MINGW32 /o/src/uasm
$ make -f Makefile_LinuxGCC
g++ -D __UNIX__ -c -IH -D __UNIX__ -DNDEBUG -O2 -ansi -funsigned-char  -o GccUnixR/main.o main.c
In file included from H/globals.h:199,
                 from main.c:13:
H/bool.h:35:27: error: redeclaration of C++ built-in type 'bool' [-fpermissive]
   35 |     typedef unsigned char bool;
      |                           ^~~~
In file included from H/codegenv2.h:4,
                 from main.c:17:
H/expreval.h:118:22: error: only declarations of constructors and conversion operators can be 'explicit'
  118 |             unsigned explicit : 1;  /* Whether expression type explicitly given (to be removed!) */
      |                      ^~~~~~~~
main.c: In function 'int main(int, char**)':
main.c:94:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   94 |                 pEnv = "";
      |                        ^~
make: *** [Makefile_LinuxGCC:34: GccUnixR/main.o] Error 1

And after adding -fpermissive I see this problem:

$ make -f Makefile_LinuxGCC
g++ -D __UNIX__ -c -IH -D __UNIX__ -DNDEBUG -O2 -ansi -funsigned-char -fpermissive  -o GccUnixR/main.o main.c
In file included from H/globals.h:199,
                 from main.c:13:
H/bool.h:35:27: warning: redeclaration of C++ built-in type 'bool' [-fpermissive]
   35 |     typedef unsigned char bool;
      |                           ^~~~
In file included from H/codegenv2.h:4,
                 from main.c:17:
H/expreval.h:118:22: error: only declarations of constructors and conversion operators can be 'explicit'
  118 |             unsigned explicit : 1;  /* Whether expression type explicitly given (to be removed!) */
      |                      ^~~~~~~~
main.c: In function 'int main(int, char**)':
main.c:94:24: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   94 |                 pEnv = "";
      |                        ^~
make: *** [Makefile_LinuxGCC:34: GccUnixR/main.o] Error 1

Please note that "explicit" is a C++ keyword, you must not use it for anything.

After fixing this I have found that -ansi switch is unwanted, see reason https://stackoverflow.com/questions/2223541/why-cant-i-use-style-comments-in-my-c-code

In file included from assemble.c:59:
H/bin.h:17:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
   17 | #endif // _BIN_H_INCLUDED_
      |        ^
In file included from assemble.c:62:
H/macho64.h:9:8: warning: extra tokens at end of #endif directive [-Wendif-labels]
    9 | #endif // _MACHO64_H_INCLUDED_
      |        ^
assemble.c:65:8: error: operator '/' has no right operand
   65 | #if 1 //def __SW_BD
      |        ^
assemble.c:545: warning: "is_valid_first_char" redefined
  545 | #define is_valid_first_char( ch )  ( isalpha(ch) || ch=='_' || ch=='@' || ch=='$' || ch=='?' || ch=='.' )
      |
H/globals.h:258: note: this is the location of the previous definition
  258 | #define is_valid_first_char( c ) ((_ltype[(unsigned char)(c) + 1] & _LABEL) || ((c) == '.' ))
      |
assemble.c: In function 'AssembleModule':
assemble.c:1611:8: error: operator '/' has no right operand
 1611 | #if 1 //def __SW_BD
      |        ^
make: *** [Makefile_LinuxGCC:34: GccUnixR/assemble.o] Error 1

Seems to be mission impossible to get this compilled:

dbgcv.c: In function 'cv_write_debug_tables':
dbgcv.c:1578:55: error: invalid operands to binary - (have 'char *' and 'uint_8 *' {aka 'unsigned char *'})
 1578 |                 EnvBlock->reclen = (unsigned short)(s - cv.ps - 2);
      |                                                       ^ ~~~~~
      |                                                           |
      |                                                           uint_8 * {aka unsigned char *}
dbgcv.c:1583:42: error: invalid operands to binary - (have 'char *' and 'uint_8 *' {aka 'unsigned char *'})
 1583 |                 cv.section->length += (s - start);
      |                                          ^
make: *** [Makefile_LinuxGCC:34: GccUnixR/dbgcv.o] Error 1
Fojtik commented 3 months ago

This is just a script code fragment that checks neccessity of -fpermisive

####### Check default arg in friend function ######
default_arg_flaw='no'

AC_MSG_CHECKING(whether friend function could have a default arg )

AC_LANG(C++)
AC_TRY_COMPILE(
    [
    class MyClassNo1 {
    public:   MyClassNo1(unsigned len);

    friend int MyFriendFunc(const MyClassNo1 & s, char c='1');
    };
    ],
    [],
    default_arg_flaw='no',
    default_arg_flaw='yes')

if test "$default_arg_flaw" == 'yes' 
then
  CXXFLAGS="$CXXFLAGS -fpermissive"
  echo "no - fix -fpermissive used"
else
  echo "yes"
fi