osu-ds icon indicating copy to clipboard operation
osu-ds copied to clipboard

Error in gfxconsole.c

Open 10kmotorola opened this issue 2 years ago • 1 comments

I get the following error when attempting to build:

gfxconsole.c
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c:487:9: error: initialization of 'ssize_t (*)(struct _reent *, void *, const char *, size_t)' {aka 'int (*)(struct _reent *, void *, const char *, unsigned int)'} from incompatible pointer type 'ssize_t (*)(struct _reent *, int,  const char *, size_t)' {aka 'int (*)(struct _reent *, int,  const char *, unsigned int)'} [-Wincompatible-pointer-types]
  487 |         gfxcon_write,
      |         ^~~~~~~~~~~~
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c:487:9: note: (near initialization for 'dotab_gfxstdout.write_r')
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c:499:9: error: initialization of 'ssize_t (*)(struct _reent *, void *, const char *, size_t)' {aka 'int (*)(struct _reent *, void *, const char *, unsigned int)'} from incompatible pointer type 'ssize_t (*)(struct _reent *, int,  const char *, size_t)' {aka 'int (*)(struct _reent *, int,  const char *, unsigned int)'} [-Wincompatible-pointer-types]
  499 |         gfxnocash_write,
      |         ^~~~~~~~~~~~~~~
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c:499:9: note: (near initialization for 'dotab_gfxstderr.write_r')
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c: In function 'gfxConsolePrintChar':
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c:663:103: warning: array subscript has type 'char' [-Wchar-subscripts]
  663 |         if( ( gfxcurrentConsole->cursorX + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c]->bShift) > gfxcurrentConsole->windowWidth) {
      |                                                                                                       ^
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c:705:88: warning: array subscript has type 'char' [-Wchar-subscripts]
  705 |                         if( gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c] )
      |                                                                                        ^
/home/orchid/Git/osu-ds/source/Libraries/gfxconsole.c:712:122: warning: array subscript has type 'char' [-Wchar-subscripts]
  712 |                                 gfxcurrentConsole->cursorX += gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Ltrs[c]->bShift + gfxcurrentConsole->font[ gfxcurrentConsole->curFont ]->Head->bAddSpace;
      |                                                                                                                          ^
make[1]: *** [/opt/devkitpro/devkitARM/base_rules:39: gfxconsole.o] Error 1
make: *** [Makefile:116: build] Error 2

I have no clue if this is just a dependency issue or something simple I'm missing, but any help is more than appreciated :)

10kmotorola avatar Jun 13 '24 06:06 10kmotorola

I had the same problem. Basically, the compiler is being strict, not accepting int as void pointer. The sad part is that most of those pointer are not being used at all. I fixed these here in my code. I think you can convert the below code in a patch and apply to the code. Sorry, don't know how to do a pull request in here.

diff --git a/source/Libraries/gfxconsole.c b/source/Libraries/gfxconsole.c
index a4b47be..7f17e71 100644
--- a/source/Libraries/gfxconsole.c
+++ b/source/Libraries/gfxconsole.c
@@ -197,8 +197,9 @@ static void gfxConsoleClearLine(char mode) {
 }
 
 //---------------------------------------------------------------------------------
-ssize_t gfxnocash_write(struct _reent *r, int fd, const char *ptr, size_t len) {
+ssize_t gfxnocash_write(struct _reent *r, void* fd,const char *ptr, size_t len) {
 	//---------------------------------------------------------------------------------
+	
 	int count = 0;
 
 	if(!ptr || len <= 0) return -1;
@@ -217,9 +218,9 @@ ssize_t gfxnocash_write(struct _reent *r, int fd, const char *ptr, size_t len) {
 
 
 //---------------------------------------------------------------------------------
-ssize_t gfxcon_write(struct _reent *r,int fd,const char *ptr, size_t len) {
+ssize_t gfxcon_write(struct _reent *r,void* fd,const char *ptr, size_t len) {
 	//---------------------------------------------------------------------------------
-	
+	int fd_int = (int)(intptr_t)fd;
 	char chr;
 
 	int i, count = 0;
diff --git a/source/Libraries/nitrofs.c b/source/Libraries/nitrofs.c
index 8e5846e..f3190aa 100644
--- a/source/Libraries/nitrofs.c
+++ b/source/Libraries/nitrofs.c
@@ -318,11 +318,12 @@ int nitroFSOpen(struct _reent *r, void *fileStruct, const char *path,int flags,i
 	return(-1);	//teh fail
 }
 
-int nitroFSClose(struct _reent *r,int fd) {
+int nitroFSClose(struct _reent *r,void *fd) {
 	return(0);
 }
 
-int nitroFSRead(struct _reent *r,int fd,char *ptr,int len) {
+int nitroFSRead(struct _reent *r,void *fd,char *ptr, unsigned int len) {
+	
 	struct nitroFSStruct *fatStruct=(struct nitroFSStruct *)fd;
 	unsigned int *npos=&fatStruct->pos;
 	if(*npos+len > fatStruct->end) 
@@ -332,7 +333,7 @@ int nitroFSRead(struct _reent *r,int fd,char *ptr,int len) {
 	return(nitroSubRead(npos,ptr,len));
 }
 
-int nitroFSSeek(struct _reent *r,int fd,int pos,int dir) {
+long long int nitroFSSeek(struct _reent *r,void *fd,long long int pos,int dir) {
 	//need check for eof here...
 	struct nitroFSStruct *fatStruct=(struct nitroFSStruct *)fd;
 	unsigned int *npos=&fatStruct->pos;
@@ -346,7 +347,7 @@ int nitroFSSeek(struct _reent *r,int fd,int pos,int dir) {
 	return(*npos-fatStruct->start);
 }
 
-int nitroFSFstat(struct _reent *r,int fd,struct stat *st) {
+int nitroFSFstat(struct _reent *r,void *fd,struct stat *st) {
 	struct nitroFSStruct *fatStruct=(struct nitroFSStruct *)fd;
 	st->st_size=fatStruct->end-fatStruct->start;
 	return(0);	
diff --git a/source/Libraries/nitrofs.h b/source/Libraries/nitrofs.h
index 630fd0c..b767431 100644
--- a/source/Libraries/nitrofs.h
+++ b/source/Libraries/nitrofs.h
@@ -54,10 +54,10 @@ int nitroDirReset(struct _reent *r, DIR_ITER *dirState);
 int nitroFSDirNext(struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *st);
 int nitroFSDirClose(struct _reent *r, DIR_ITER *dirState);
 int nitroFSOpen(struct _reent *r, void *fileStruct, const char *path,int flags,int mode);
-int nitroFSClose(struct _reent *r,int fd);
-int nitroFSRead(struct _reent *r,int fd,char *ptr,int len);
-int nitroFSSeek(struct _reent *r,int fd,int pos,int dir);
-int nitroFSFstat(struct _reent *r,int fd,struct stat *st);
+int nitroFSClose(struct _reent *r,void *fd);
+int nitroFSRead(struct _reent *r,void *fd,char *ptr,unsigned int len);
+long long int nitroFSSeek(struct _reent *r,void *fd,long long int pos,int dir);
+int nitroFSFstat(struct _reent *r,void *fd,struct stat *st);
 int nitroFSstat(struct _reent *r,const char *file,struct stat *st);
 int nitroFSChdir(struct _reent *r,const char *name);
 #define LOADERSTR	"PASS"	//look for this

elissonandrade avatar Nov 11 '24 22:11 elissonandrade