Page 3 of 5

Re: DMCP_SDK Hello World

Posted: Sat Jun 16, 2018 7:42 pm
by ijabbott
Vitasam wrote:
Thu Jun 14, 2018 10:56 pm
ijabbott wrote:
Thu Jun 14, 2018 10:38 pm
What if you add -std=c99 or -std=c11?
But what is a policy of DM42 SDK - are we C99 compliant?

With following options:

Code: Select all

CFLAGS += -std=c99
CFLAGS += -pedantic-errors

Code: Select all

DMCP_SDK$ make
arm-none-eabi-gcc -c -mthumb -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -Idmcp -Isrc   -Wall -fdata-sections -ffunction-sections -Wno-misleading-indentation -std=c99 -pedantic-errors -O2 -g  -MD -MP -MF .dep/pgm_syscalls.o.d -Wa,-a,-ad,-alms=build/pgm_syscalls.lst dmcp/sys/pgm_syscalls.c -o build/pgm_syscalls.o
In file included from dmcp/sys/pgm_syscalls.c:44:0:
dmcp/dmcp.h:474:14: error: redefinition of typedef 'void_fn_t' [-Wpedantic]
 typedef void void_fn_t();
              ^
dmcp/dmcp.h:285:14: note: previous declaration of 'void_fn_t' was here
 typedef void void_fn_t();
              ^
dmcp/sys/pgm_syscalls.c:54:2: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  (void*)Program_Entry,  // void * pgm_entry;
  ^
dmcp/sys/pgm_syscalls.c: In function 'free':
dmcp/sys/pgm_syscalls.c:113:2: error: implicit declaration of function 'typeof' [-Wimplicit-function-declaration]
  __sysfn_free(ptr);
  ^
In file included from dmcp/dmcp.h:841:0,
                 from dmcp/sys/pgm_syscalls.c:44:
dmcp/lft_ifc.h:38:38: error: expected expression before ')' token
 #define __sysfn_free (*(typeof(free)*)(LIBRARY_FN_BASE+4))
                                      ^
dmcp/sys/pgm_syscalls.c:113:2: note: in expansion of macro '__sysfn_free'
  __sysfn_free(ptr);
  ^
dmcp/sys/pgm_syscalls.c: In function 'malloc':
dmcp/lft_ifc.h:37:42: error: expected expression before ')' token
 #define __sysfn_malloc (*(typeof(malloc)*)(LIBRARY_FN_BASE+0))
                                          ^
dmcp/sys/pgm_syscalls.c:118:9: note: in expansion of macro '__sysfn_malloc'
  return __sysfn_malloc(size);
         ^
dmcp/sys/pgm_syscalls.c: In function 'calloc':
dmcp/lft_ifc.h:39:42: error: expected expression before ')' token
 #define __sysfn_calloc (*(typeof(calloc)*)(LIBRARY_FN_BASE+8))
                                          ^
dmcp/sys/pgm_syscalls.c:123:9: note: in expansion of macro '__sysfn_calloc'
  return __sysfn_calloc(count, nbytes);
         ^
dmcp/sys/pgm_syscalls.c: In function 'realloc':
dmcp/lft_ifc.h:40:44: error: expected expression before ')' token
 #define __sysfn_realloc (*(typeof(realloc)*)(LIBRARY_FN_BASE+12))
                                            ^
dmcp/sys/pgm_syscalls.c:127:9: note: in expansion of macro '__sysfn_realloc'
  return __sysfn_realloc(ptr, size);
         ^
dmcp/sys/pgm_syscalls.c: In function 'post_main':
dmcp/lft_ifc.h:105:52: error: expected expression before ')' token
 #define set_reset_magic (*(typeof(set_reset_magic)*)(LIBRARY_FN_BASE+272))
                                                    ^
dmcp/sys/pgm_syscalls.c:151:2: note: in expansion of macro 'set_reset_magic'
  set_reset_magic(RUN_DMCP_MAGIC);
  ^
dmcp/lft_ifc.h:173:40: error: expected expression before ')' token
 #define sys_reset (*(typeof(sys_reset)*)(LIBRARY_FN_BASE+544))
                                        ^
dmcp/sys/pgm_syscalls.c:152:2: note: in expansion of macro 'sys_reset'
  sys_reset();
  ^
/usr/include/newlib/stdlib.h: In function 'malloc':
dmcp/sys/pgm_syscalls.c:119:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/usr/include/newlib/stdlib.h: In function 'calloc':
dmcp/sys/pgm_syscalls.c:124:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/usr/include/newlib/stdlib.h: In function 'realloc':
dmcp/sys/pgm_syscalls.c:128:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
dmcp/sys/pgm_syscalls.c: At top level:
cc1: warning: unrecognized command line option "-Wno-misleading-indentation"
Makefile:132: recipe for target 'build/pgm_syscalls.o' failed
make: *** [build/pgm_syscalls.o] Error 1
Some of those could be fixed, but avoiding the typeof keyword (a GCC extension) would make the dmcp/lft_ifc.h header file a lot uglier than it is already.

Also, the C++ sources make use of variable length arrays (VLAs) which are not standard C++, so that would have to be worked around somehow. Not sure it's worth it.

However, using -pedantic is useful for spotting some places that could easily be made more standard.

Setting CFLAGS += -std=c99 in the Makefile currently makes that end up in CXXFLAGS too, so it would need a bit of Makefile hacking to separate the "C only" flags from the "C and C++" flags.

Re: DMCP_SDK Hello World

Posted: Mon Oct 01, 2018 3:12 pm
by Vitasam
Hello,
is it possible to use smaller (and, preferably monospace) font? Having trouble to fit Super Star-Trek status screen there :)

How to set monospace font?

Posted: Wed Oct 03, 2018 10:00 pm
by Vitasam
Hello,
I've managed to reduce the font size, now status-screen of StarTrek game fits to the screen.

Question: how to select a monospace font, if any?

Re: DMCP_SDK Hello World

Posted: Wed Oct 03, 2018 10:11 pm
by Walter
Dunno about the spelling at stardate 4900, but nowadays torpedos are torpedos (don't take this personally: even American presidents have difficulties with this trailing syllable in plural ;)).

Super StarTrek at DM42

Posted: Wed Oct 03, 2018 10:22 pm
by Vitasam
Walter wrote:
Wed Oct 03, 2018 10:11 pm
Dunno about the spelling at stardate 4900, but nowadays torpedos are torpedos (don't take this personally: even American presidents have difficulties with this trailing syllable in plural ;)).
:D Good to know! But, perhaps it is just a tribute to the legendary game, I just copy/pasted status-screen from Github repository.

Nevertheless, without monospace font that screen looks depressing.

Re: DMCP_SDK Hello World

Posted: Wed Oct 03, 2018 11:26 pm
by ijabbott
Walter wrote:
Wed Oct 03, 2018 10:11 pm
Dunno about the spelling at stardate 4900, but nowadays torpedos are torpedos (don't take this personally: even American presidents have difficulties with this trailing syllable in plural ;)).
I'm pretty sure torpedoes is correct.

Re: DMCP_SDK Hello World

Posted: Thu Oct 04, 2018 4:28 am
by Walter
ijabbott wrote:
Wed Oct 03, 2018 11:26 pm
I'm pretty sure torpedoes is correct.
I stand corrected. It just looks strange to me. :?

Re: DMCP_SDK Hello World

Posted: Thu Oct 04, 2018 6:07 am
by keithdalby
Walter wrote:
Thu Oct 04, 2018 4:28 am
It just looks strange to me. :?
Don't take it personally: even American presidents have difficulties with this.

Re: DMCP_SDK Hello World

Posted: Thu Oct 04, 2018 6:48 am
by Walter
keithdalby wrote:
Thu Oct 04, 2018 6:07 am
Walter wrote:
Thu Oct 04, 2018 4:28 am
It just looks strange to me. :?
Don't take it personally: even American presidents have difficulties with this.
:lol: Expected something like that. My fault. :D

Re: DMCP_SDK Hello World

Posted: Thu Oct 04, 2018 10:04 pm
by toml_12953
Walter wrote:
Wed Oct 03, 2018 10:11 pm
Dunno about the spelling at stardate 4900, but nowadays torpedos are torpedos (don't take this personally: even American presidents have difficulties with this trailing syllable in plural ;)).
In the USA, either way is acceptable with words ending in o (potato, tomato, torpedo, etc.) in fact most people I know still use the e.