Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The compiler hates this, spits out tons of errors #3

Open
NeoTechni opened this issue Mar 6, 2024 · 5 comments
Open

The compiler hates this, spits out tons of errors #3

NeoTechni opened this issue Mar 6, 2024 · 5 comments

Comments

@NeoTechni
Copy link

E:/VB6/GBA/Projects/Awakening/source/gba_flash.c: In function 'wait_until':
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:75:99: warning: pointer targets in passing argument 2 of 'flash_absmemcmp' differ in signedness [-Wpointer-sign]
75 | for (vu32 i = 0; i < LOOP_CNT_PER_MILLI_SECOND * timeout && flash_absmemcmp(&flash_mem[addr], data, 1); i++);
| ^~~~
| |
| const char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:57:102: note: expected 'const volatile unsigned char *' but argument is of type 'const char *'
57 | static unsigned int flash_absmemcmp(const volatile unsigned char *dst, const volatile unsigned char *src, size_t size) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:77:43: warning: pointer targets in passing argument 2 of 'flash_absmemcmp' differ in signedness [-Wpointer-sign]
77 | if (flash_absmemcmp(&flash_mem[addr], data, 1)) {
| ^~~~
| |
| const char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:57:102: note: expected 'const volatile unsigned char *' but argument is of type 'const char *'
57 | static unsigned int flash_absmemcmp(const volatile unsigned char *dst, const volatile unsigned char *src, size_t size) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c: In function 'flash_reset':
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:143:25: warning: pointer targets in passing argument 2 of 'wait_until' differ in signedness [-Wpointer-sign]
143 | err = wait_until(0, &erased_byte_value, 20);
| ^~~~~~~~~~~~~~~~~~
| |
| const unsigned char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:74:45: note: expected 'const char *' but argument is of type 'const unsigned char *'
74 | static int wait_until(u32 addr, const char *data, int timeout) {
| ~~~~~~~~~~~~^~~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:146:30: warning: pointer targets in passing argument 2 of 'wait_until' differ in signedness [-Wpointer-sign]
146 | return wait_until(0, &erased_byte_value_vba, 20);
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| const unsigned char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:74:45: note: expected 'const char *' but argument is of type 'const unsigned char *'
74 | static int wait_until(u32 addr, const char *data, int timeout) {
| ~~~~~~~~~~~~^~~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c: In function 'flash_erase':
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:166:28: warning: pointer targets in passing argument 2 of 'wait_until' differ in signedness [-Wpointer-sign]
166 | err = wait_until(addr, &erased_byte_value, 20);
| ^~~~~~~~~~~~~~~~~~
| |
| const unsigned char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:74:45: note: expected 'const char *' but argument is of type 'const unsigned char *'
74 | static int wait_until(u32 addr, const char *data, int timeout) {
| ~~~~~~~~~~~~^~~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:169:30: warning: pointer targets in passing argument 2 of 'wait_until' differ in signedness [-Wpointer-sign]
169 | return wait_until(0, &erased_byte_value_vba, 20);
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| const unsigned char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:74:45: note: expected 'const char *' but argument is of type 'const unsigned char *'
74 | static int wait_until(u32 addr, const char *data, int timeout) {
| ~~~~~~~~~~~~^~~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c: In function 'flash_read':
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:210:18: warning: pointer targets in passing argument 1 of 'flash_memcpy' differ in signedness [-Wpointer-sign]
210 | flash_memcpy(data, &flash_mem[addr], size);
| ^~~~
| |
| char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:51:50: note: expected 'volatile unsigned char *' but argument is of type 'char *'
51 | static void flash_memcpy(volatile unsigned char *dst, const volatile unsigned char *src, size_t size) {
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c: In function 'flash_write_byte':
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:224:29: warning: pointer targets in passing argument 2 of 'wait_until' differ in signedness [-Wpointer-sign]
224 | return wait_until(addr, &data, 20);
| ^~~~~
| |
| u8 * {aka unsigned char *}
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:74:45: note: expected 'const char *' but argument is of type 'u8 *' {aka 'unsigned char *'}
74 | static int wait_until(u32 addr, const char *data, int timeout) {
| ~~~~~~~~~~~~^~~~
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c: In function 'flash_write':
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:346:43: warning: pointer targets in passing argument 2 of 'flash_absmemcmp' differ in signedness [-Wpointer-sign]
346 | if (flash_absmemcmp(&flash_mem[addr], data, size))
| ^~~~
| |
| char *
E:/VB6/GBA/Projects/Awakening/source/gba_flash.c:57:102: note: expected 'const volatile unsigned char *' but argument is of type 'char *'
57 | static unsigned int flash_absmemcmp(const volatile unsigned char *dst, const volatile unsigned char *src, size_t size) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
gba_sram.c
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c: In function 'sram_read':
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c:35:17: warning: pointer targets in passing argument 1 of 'sram_memcpy' differ in signedness [-Wpointer-sign]
35 | sram_memcpy(data, &sram_mem[addr], size);
| ^~~~
| |
| char *
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c:8:49: note: expected 'volatile unsigned char *' but argument is of type 'char *'
8 | static void sram_memcpy(volatile unsigned char *dst, const volatile unsigned char *src, size_t size) {
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c: In function 'sram_write':
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c:50:34: warning: pointer targets in passing argument 2 of 'sram_memcpy' differ in signedness [-Wpointer-sign]
50 | sram_memcpy(&sram_mem[addr], data, size);
| ^~~~
| |
| char *
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c:8:84: note: expected 'const volatile unsigned char *' but argument is of type 'char *'
8 | static void sram_memcpy(volatile unsigned char *dst, const volatile unsigned char *src, size_t size) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c:52:41: warning: pointer targets in passing argument 2 of 'sram_absmemcmp' differ in signedness [-Wpointer-sign]
52 | if (sram_absmemcmp(&sram_mem[addr], data, size))
| ^~~~
| |
| char *
E:/VB6/GBA/Projects/Awakening/source/gba_sram.c:14:101: note: expected 'const volatile unsigned char *' but argument is of type 'char *'
14 | static unsigned int sram_absmemcmp(const volatile unsigned char *dst, const volatile unsigned char *src, size_t size) {

@aronson
Copy link

aronson commented Mar 17, 2024

Had a chance to chat on Discord in GBADEV. This user copied the sources into their project and redefined a few things in the global namespace the project relies on. They were able to build the project on its own no problem standalone. I'd close this as a non-issue.

@NeoTechni
Copy link
Author

NeoTechni commented Mar 17, 2024 via email

@aronson
Copy link

aronson commented Mar 17, 2024

I still can't use it

I gave you detailed instructions on Discord on how everyone else has been using this with success. If you "still can't use it" after that, I'm going to wager the issue is lack of expending effort in lieu of meaningful feedback.

As I said before, you cannot expect to copy an entire library into a foreign source tree and expect it to work. This is not the fault of the library. This is on you, the developer. I understand you copied someone else's code, why you don't copy someone else's general workflow and link the binary?

If you really want to solve it on your own, here's all your issues from your compiler output summarized with clear descriptions of the problem:

1. Mismatch in flash_absmemcmp Function Calls

  • Issue: The function expects arguments of type const volatile unsigned char *, but arguments of type const char * and char * are passed instead.
  • Example Warning: pointer targets in passing argument 2 of 'flash_absmemcmp' differ in signedness [-Wpointer-sign]

2. Mismatch in wait_until Function Calls

  • Issue: The function expects arguments of type const char *, but arguments of type const unsigned char * and u8 * (aka unsigned char *) are passed instead.
  • Example Warning: pointer targets in passing argument 2 of 'wait_until' differ in signedness [-Wpointer-sign]

3. Mismatch in flash_memcpy Function Calls

  • Issue: The function expects the first argument of type volatile unsigned char *, but an argument of type char * is passed instead.
  • Example Warning: pointer targets in passing argument 1 of 'flash_memcpy' differ in signedness [-Wpointer-sign]

4. Mismatch in sram_memcpy Function Calls

  • Issue: Similar to flash_memcpy, the function expects the first argument of type volatile unsigned char * and the second argument of type const volatile unsigned char *, but arguments of type char * are passed instead.
  • Example Warning: pointer targets in passing argument 1 of 'sram_memcpy' differ in signedness [-Wpointer-sign]

5. Mismatch in sram_absmemcmp Function Calls

  • Issue: The function expects arguments of type const volatile unsigned char *, but arguments of type char * are passed instead.
  • Example Warning: pointer targets in passing argument 2 of 'sram_absmemcmp' differ in signedness [-Wpointer-sign]

@NeoTechni
Copy link
Author

NeoTechni commented Mar 17, 2024 via email

@aronson
Copy link

aronson commented Mar 17, 2024

Reposting what I posted in Discord so that anyone who runs into this in the future can avoid all these errors:

You can avoid that by using the headers and linking to the libsavgba.a file
This might come up again if you want to bring in another library
you would put the headers in your include dir and use the code like usual. You would add the linker flags -lsavgba and the path to the library .a file -L/path/to/containing/folder
many people put stuff like this in a lib/ folder in the project dir to make it portable
I think the usual GBA makefile lets you adjust this with LDLIBS and LDFLAGS at the top

Good luck on your projects! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants