Blinkinlabs / ch554_sdcc

CH554 software development kit for SDCC
306 stars 71 forks source link

Fix touchkey build error, missing make flash prerequisite, and ignore binaries #6

Closed mogenson closed 6 years ago

mogenson commented 6 years ago

Match getchar() and putchar() function declarations to SDCC

The touchkey example build fails with:

```
error 91: extern definition for 'putchar' mismatches with declaration.
error 91: extern definition for 'getchar' mismatches with declaration.
```

SDCC complains that the putchar() and getchar() function declarations in
include/debug.h don't match those from SDCC's stdio.h. Make the
parameters and return types match what SDCC expects.

https://sourceforge.net/p/sdcc/code/HEAD/tree/trunk/sdcc/device/include/stdio.h#l85

Add pre-flash make rule to examples for make flash

The 'make flash' rule in Makefile.include expects a 'pre-flash'
prerequisite. Add this 'pre-flash' rule to the examples that are missing
it so that every example works with 'make flash'.

Tell git to ignore generated si5351 binary

Add local .gitignore file to tell git to ignore the compiled si5351
executable for the 'usb_device_cdc_i2c/commandline' example. This will
make sure it's not accidentally committed.

sdcc --version

SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.7.0 #10231 (Linux)
mogenson commented 6 years ago

Looks like the SDCC prototypes in stdio.h were changed in August of 2017.

https://sourceforge.net/p/sdcc/code/9989/tree//trunk/sdcc/device/include/stdio.h?diff=513f4d42271846342871488b:9988

The Travis container is using SDCC version 3.3 for Ubuntu 14.04 from 2013.

cibomahto commented 6 years ago

Good point, however I think forcing a newer version of SDCC will break anyone who's using one of the stable downloads, since they are all 3.6 which predates this change: https://sourceforge.net/projects/sdcc/files/sdcc-linux-x86/ https://sourceforge.net/projects/sdcc/files/sdcc-win64/ https://sourceforge.net/projects/sdcc/files/sdcc-macosx/

Per the manual, this feature was introduced in SDCC 3.7: http://sdcc.sourceforge.net/doc/sdccman.pdf • In 3.7.0, the prototype for putchar() changed from void putchar(char) to int putchar(int)

so it looks like bracketing them in a conditional like this:

#if SDCC < 370
void putchar(char data);    
char getchar(); 
#else
int putchar(int c);
int getchar(void);
#endif

should allow this to be version agnostic.

I suppose passing around 16-bit variables and then masking them out casually is a good reminder not to use printf unless absolutely necessary ;-)

mogenson commented 6 years ago

Updated the pull request with conditionals.

cibomahto commented 6 years ago

Thanks!