From d05701705273002c096ae0e039993d5be41c9dc1 Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Fri, 12 May 2023 19:53:27 +0100 Subject: [PATCH] Switch to C++, remove externs, fix warnings --- demo/audio.cpp | 1 - demo/donut.cpp | 5 ++--- demo/helloc.cpp | 1 - demo/hellocpp.cpp | 6 ++---- demo/leds.cpp | 1 - demo/main.cpp | 12 ++++++------ 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/demo/audio.cpp b/demo/audio.cpp index 088c718..81eaabf 100644 --- a/demo/audio.cpp +++ b/demo/audio.cpp @@ -1,7 +1,6 @@ #include #include -extern "C" void audio(int); void audio(int v) { audio_targ_write(v); } \ No newline at end of file diff --git a/demo/donut.cpp b/demo/donut.cpp index eab0905..2acc07b 100644 --- a/demo/donut.cpp +++ b/demo/donut.cpp @@ -15,13 +15,12 @@ _=x; \ x -= mul*y>>shift; \ y += mul*_>>shift; \ - _ = 3145728-x*x-y*y>>11; \ + _ = (3145728-x*x-y*y)>>11; \ x = x*_>>10; \ y = y*_>>10; signed char b[1760], z[1760]; -void donut(void); void donut(void) { int sA=1024,cA=0,sB=1024,cB=0,_; for (;;) { @@ -43,7 +42,7 @@ void donut(void) { x7 = cj*si >> 10, x = 40 + 30*(cB*x1 - sB*x4)/x6, y = 12 + 15*(cB*x4 + sB*x1)/x6, - N = (-cA*x7 - cB*((-sA*x7>>10) + x2) - ci*(cj*sB >> 10) >> 10) - x5 >> 7; + N = (((-cA*x7 - cB*((-sA*x7>>10) + x2) - ci*(cj*sB >> 10)) >> 10) - x5) >> 7; int o = x + 80 * y; signed char zz = (x6-K2)>>15; diff --git a/demo/helloc.cpp b/demo/helloc.cpp index dd15abb..4591772 100644 --- a/demo/helloc.cpp +++ b/demo/helloc.cpp @@ -1,6 +1,5 @@ #include -void helloc(void); void helloc(void) { printf("C: Hello, world!\n"); } \ No newline at end of file diff --git a/demo/hellocpp.cpp b/demo/hellocpp.cpp index fb9e3fe..775f205 100644 --- a/demo/hellocpp.cpp +++ b/demo/hellocpp.cpp @@ -1,7 +1,5 @@ #include -extern "C" void hellocpp(void); -void hellocpp(void) -{ - printf("C++: Hello, world!\n"); +void hellocpp(void) { + printf("C++: Hello, world!\n"); } \ No newline at end of file diff --git a/demo/leds.cpp b/demo/leds.cpp index 072ea2d..7a3d97d 100644 --- a/demo/leds.cpp +++ b/demo/leds.cpp @@ -1,7 +1,6 @@ #include #include -extern "C" void leds(int); void leds(int v) { leds_out_write(v); } \ No newline at end of file diff --git a/demo/main.cpp b/demo/main.cpp index df3789f..597b849 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -17,7 +17,7 @@ static char *readstr(void) { char c[2]; static char s[64]; - static int ptr = 0; + static unsigned int ptr = 0; if (readchar_nonblock()) { c[0] = getchar(); @@ -144,7 +144,7 @@ static void led_cmd(void) { #endif #ifdef CSR_LEDS_BASE -extern "C" void leds(int); +void leds(int); static void leds_cmd(char **val) { int value = (int)strtol(get_token(val), NULL, 0); @@ -153,7 +153,7 @@ static void leds_cmd(char **val) { } #endif #ifdef CSR_AUDIO_BASE -extern "C" void audio(int); +void audio(int); static void audio_cmd(char **val) { int value = (int)strtol(get_token(val), NULL, 0); @@ -162,21 +162,21 @@ static void audio_cmd(char **val) { } #endif -extern "C" void donut(void); +void donut(void); static void donut_cmd(void) { printf("Donut demo...\n"); donut(); } -extern "C" void helloc(void); +void helloc(void); static void helloc_cmd(void) { printf("Hello C demo...\n"); helloc(); } -extern "C" void hellocpp(void); +void hellocpp(void); static void hellocpp_cmd(void) { printf("Hello C++ demo...\n");