mfld-fr / emu86

Intel IA16 emulator for embedded development
35 stars 6 forks source link

Warnings now errors in macOS port #59

Closed ghaerr closed 3 years ago

ghaerr commented 3 years ago

The addition of -Werror in Makefile prohibits macOS (running with off_t = long long) from compiling. Here is compilation with -Werror removed:

cc -g -Wall -DSDL=1 -DELKS   -c -o emu-main.o emu-main.c
emu-main.c:54:37: warning: format specifies type 'unsigned long' but the argument has type
      'off_t' (aka 'long long') [-Wformat]
                printf ("info: file size=%lXh\n", size);
                                         ~~~      ^~~~
                                         %llX
1 warning generated.
cc -g -Wall -DSDL=1 -DELKS   -c -o op-print-intel.o op-print-intel.c
cc -g -Wall -DSDL=1 -DELKS   -c -o emu-con.o emu-con.c
cc -g -Wall -DSDL=1 -DELKS   -c -o con-sdl.o con-sdl.c
cc -g -Wall -DSDL=1 -DELKS   -c -o rom8x16.o rom8x16.c
cc -g -Wall -DSDL=1 -DELKS   -c -o serial-none.o serial-none.c
cc -g -Wall -DSDL=1 -DELKS   -c -o rom-elks.o rom-elks.c
rom-elks.c:155:58: warning: format specifies type 'unsigned short' but the argument has
      type 'byte_t' (aka 'unsigned char') [-Wformat]
                        printf ("\nerror: INT 10h AH=%hXh not implemented\n", ah);
                                                     ~~~                      ^~
                                                     %hhX
rom-elks.c:350:59: warning: format specifies type 'unsigned short' but the argument has
      type 'byte_t' (aka 'unsigned char') [-Wformat]
  ...printf("INT 13h AH=%hxh: invalid DCHS %d/%d/%d/%d\n", ah, d, c, h, s);
                        ~~~                                ^~
                        %hhx
rom-elks.c:356:69: warning: format specifies type 'unsigned short' but the argument has
      type 'byte_t' (aka 'unsigned char') [-Wformat]
  ...printf("INT 13h AH=%hxh: multi-track I/O operation rejected\n", ah);
                        ~~~                                          ^~
                        %hhx
rom-elks.c:387:58: warning: format specifies type 'unsigned short' but the argument has
      type 'byte_t' (aka 'unsigned char') [-Wformat]
                        printf ("\nerror: INT 13h AH=%hXh not implemented\n", ah);
                                                     ~~~                      ^~
                                                     %hhX
rom-elks.c:488:58: warning: format specifies type 'unsigned short' but the argument has
      type 'byte_t' (aka 'unsigned char') [-Wformat]
                        printf ("\nerror: INT 16h AH=%hXh not implemented\n", ah);
                                                     ~~~                      ^~
                                                     %hhX
rom-elks.c:504:59: warning: format specifies type 'unsigned short' but the argument has
      type 'byte_t' (aka 'unsigned char') [-Wformat]
                        printf ("\nerror: INT 17h: AH=%hXh not implemented\n", ah);
                                                      ~~~                      ^~
                                                      %hhX
rom-elks.c:545:59: warning: format specifies type 'unsigned short' but the argument has
      type 'byte_t' (aka 'unsigned char') [-Wformat]
                        printf ("\nerror: INT 1Ah: AH=%hXh not implemented\n", ah);
                                                      ~~~                      ^~
                                                      %hhX
7 warnings generated.

These errors are likely in rom-pcxtat.c as well.

Suggest either removing -Werror or fixing printf format specifications to be portable.

ghaerr commented 3 years ago

Tested ELKS with elks and pcxtat targets, all seems to work with above fix.

ghaerr commented 3 years ago

Also, do we need to report the regular Run Failure to Github? It doesn't seem they're doing anything about it. Can that package get be removed from our YML run?

mfld-fr commented 3 years ago

I think your compiler is right : the print specs are incorrect, not only for MacOS, but also for Linux-GNU. I wonder why I did not get these warnings before with -Wall ?

ghaerr commented 3 years ago

I have gotten the warnings the whole time, I should have mentioned this earlier. macOS is running clang, not gcc, I think that's the issue.

mfld-fr commented 3 years ago

Let me try to fix these, as -Werror is recommended by many C/C++ guidelines & coding rules.

mfld-fr commented 3 years ago

About the GitHub failure, I did not find any other support channel than the 'community' for this kind of problem. I would prefer to address the failure report directly to the maintainer, not to waste time in 'kikooland'.

ghaerr commented 3 years ago

I would prefer to address the failure report directly to the maintainer, not to waste time in 'kikooland'.

Yeah, agreed. Perhaps remove SDL YML target temporarily, and try adding it again in a week or so, since it seems that's the libsdl2 dependencies are causing the problem. Continual errors on every push is distracting.

mfld-fr commented 3 years ago

As SDL is widely used, I am expecting an 'upset premium GitHub user' to complain, so just waiting it happens...

mfld-fr commented 3 years ago

Okay... let me try the 'community' :disappointed_relieved: ... https://github.community/t/libasound2-dev-install-fails-on-ubuntu-latest/179224

mfld-fr commented 3 years ago

The fix of the latest remaining warning as suggested by CLang on MacOS (see https://github.com/mfld-fr/emu86/commit/03edbba91359ab7085f68b1f641bba7fb6bee481#commitcomment-50634090) is not portable to Linux and must be surrounded a #ifdef / #endif that is MacOS or CLang specific.

@ghaerr : please do the surrounding as you are the one that compile with CLang on MacOS.

mfld-fr commented 3 years ago

Automatic build of ELKS fixed, thanks to a related post on 'Ask Ubuntu'.

mfld-fr commented 3 years ago

Could I restore the -Werror now ?

ghaerr commented 3 years ago

Could I restore the -Werror now ?

Yes.

mfld-fr commented 3 years ago

OK thanks !