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

Some compile errors and possible fixes #92

Open
versaloon opened this issue Sep 1, 2024 · 4 comments
Open

Some compile errors and possible fixes #92

versaloon opened this issue Sep 1, 2024 · 4 comments

Comments

@versaloon
Copy link

versaloon commented Sep 1, 2024

  1. src/driver/scr_fb.c

Environment: SCREEN_WIDTH/SCREEN_HEIGHT not defined

Error:
1>....\application\shell\sys\linux\applets\nanox\raw\src\drivers\scr_fb.c(96,42): error : use of undeclared identifier 'SCREEN_WIDTH'
1>....\application\shell\sys\linux\applets\nanox\raw\src\drivers\scr_fb.c(96,56): error : use of undeclared identifier 'SCREEN_HEIGHT'

Solution: add code like below like other screen drivers
#ifndef SCREEN_WIDTH
#define SCREEN_WIDTH 1024
#endif

#ifndef SCREEN_HEIGHT
#define SCREEN_HEIGHT 768
#endif

  1. src/nanox/srvfunc.c src/nanox/srvutil.c

Compiler: IAR EWARM

Error:
Error[Pe167]: argument of type "void (*)(void *)" is incompatible with parameter of type "void " D:\vsf.demo\application\shell\sys\linux\applets\nanox\raw\src\nanox\srvfunc.c 3600
Error[Pe167]: argument of type "void (
)(void *)" is incompatible with parameter of type "void *" D:\vsf.demo\application\shell\sys\linux\applets\nanox\raw\src\nanox\srvfunc.c 3609

Solution:
add type conversion, (void *)

  1. src/nanox/srvmain.c

Compiler: IAR EWARM

Error:
Error[Pe167]: argument of type "void *" is incompatible with parameter of type "sighandler_t" D:\vsf.demo\application\shell\sys\linux\applets\nanox\raw\src\nanox\srvmain.c 979

Solution:
use type conversion, (sighandler_t) instead of (void *)

  1. src/nx11/Xrm.c

Compiler: Visual Studio - clang-cl

Error:
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Xrm.c(1611,16): error : call to undeclared function '_XOpenFile'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Solution:
Add declaration: extern int _XOpenFile(_Xconst char *path, int flags);

 src/nanox/srvfunc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nanox/srvfunc.c b/src/nanox/srvfunc.c
index 4db4b27..a3f82ac 100644
--- a/src/nanox/srvfunc.c
+++ b/src/nanox/srvfunc.c
@@ -3597,7 +3597,7 @@ GrSetScreenSaverTimeout(GR_TIMEOUT timeout)
 
 	screensaver_delay = timeout * 1000;
 
-	if((timer = GdFindTimer(GsActivateScreenSaver)))
+	if((timer = GdFindTimer((void *)GsActivateScreenSaver)))
 		GdDestroyTimer(timer);
 
 	/* 0 timeout cancels timer*/
@@ -3606,7 +3606,7 @@ GrSetScreenSaverTimeout(GR_TIMEOUT timeout)
 		return;
 	}
 
-	GdAddTimer(screensaver_delay, GsActivateScreenSaver, GsActivateScreenSaver);
+	GdAddTimer(screensaver_delay, GsActivateScreenSaver, (void *)GsActivateScreenSaver);
 
 	SERVER_UNLOCK();
 #endif /* MW_FEATURE_TIMERS */
 src/nanox/srvutil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nanox/srvutil.c b/src/nanox/srvutil.c
index 8d49668..294ba5b 100644
--- a/src/nanox/srvutil.c
+++ b/src/nanox/srvutil.c
@@ -50,10 +50,10 @@ GsResetScreenSaver(void)
 	if(screensaver_delay) {
 		MWTIMER *timer;
 
-		if((timer = GdFindTimer(GsActivateScreenSaver)))
+		if((timer = GdFindTimer((void *)GsActivateScreenSaver)))
 			GdDestroyTimer(timer);
 
-		GdAddTimer(screensaver_delay, GsActivateScreenSaver, GsActivateScreenSaver);
+		GdAddTimer(screensaver_delay, GsActivateScreenSaver, (void *)GsActivateScreenSaver);
 	}
 #endif
 }
  1. src/nx11/Image.c

Compiler: Visual Studio - clang-cl

Error:
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(137,22): error : incompatible function pointer types assigning to 'unsigned long (*)(struct _XImage *, unsigned int, unsigned int)' from 'unsigned long (XImage *, int, int)' (aka 'unsigned long (struct _XImage , int, int)') [-Wincompatible-function-pointer-types]
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(138,22): error : incompatible function pointer types assigning to 'int (
)(struct _XImage *, unsigned int, unsigned int, unsigned long)' from 'int (XImage *, int, int, unsigned long)' (aka 'int (struct _XImage , int, int, unsigned long)') [-Wincompatible-function-pointer-types]
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(141,22): error : incompatible function pointer types assigning to 'unsigned long (
)(struct _XImage *, unsigned int, unsigned int)' from 'unsigned long (XImage *, int, int)' (aka 'unsigned long (struct _XImage , int, int)') [-Wincompatible-function-pointer-types]
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(142,22): error : incompatible function pointer types assigning to 'int (
)(struct _XImage *, unsigned int, unsigned int, unsigned long)' from 'int (XImage *, int, int, unsigned long)' (aka 'int (struct _XImage , int, int, unsigned long)') [-Wincompatible-function-pointer-types]
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(145,22): error : incompatible function pointer types assigning to 'unsigned long (
)(struct _XImage *, unsigned int, unsigned int)' from 'unsigned long (XImage *, int, int)' (aka 'unsigned long (struct _XImage , int, int)') [-Wincompatible-function-pointer-types]
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(146,22): error : incompatible function pointer types assigning to 'int (
)(struct _XImage *, unsigned int, unsigned int, unsigned long)' from 'int (XImage *, int, int, unsigned long)' (aka 'int (struct _XImage , int, int, unsigned long)') [-Wincompatible-function-pointer-types]
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(149,22): error : incompatible function pointer types assigning to 'unsigned long (
)(struct _XImage *, unsigned int, unsigned int)' from 'unsigned long (XImage *, int, int)' (aka 'unsigned long (struct _XImage , int, int)') [-Wincompatible-function-pointer-types]
1>....\application\shell\sys\linux\applets\nanox\raw\src\nx11\Image.c(150,22): error : incompatible function pointer types assigning to 'int (
)(struct _XImage *, unsigned int, unsigned int, unsigned long)' from 'int (XImage *, int, int, unsigned long)' (aka 'int (struct _XImage *, int, int, unsigned long)') [-Wincompatible-function-pointer-types]

Solution:
fix prototype of get_pixel/put_pixel in _XImage

 src/nx11/X11-local/X11/Xlib.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nx11/X11-local/X11/Xlib.h b/src/nx11/X11-local/X11/Xlib.h
index a7c8e89..093fbd6 100644
--- a/src/nx11/X11-local/X11/Xlib.h
+++ b/src/nx11/X11-local/X11/Xlib.h
@@ -397,8 +397,8 @@ typedef struct _XImage {
 		int		/* bitmap_pad */,
 		int		/* bytes_per_line */);
 	int (*destroy_image)        (struct _XImage *);
-	unsigned long (*get_pixel)  (struct _XImage *, unsigned int, unsigned int);
-	int (*put_pixel)            (struct _XImage *, unsigned int, unsigned int, unsigned long);
+	unsigned long (*get_pixel)  (struct _XImage *, int, int);
+	int (*put_pixel)            (struct _XImage *, int, int, unsigned long);
 	struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
 	int (*add_pixel)            (struct _XImage *, long);
 #else
  1. src/nx11/SetAttributes.c

Compiler: Visual Studio - clang-cl

Error:
1>lld-link : error : undefined symbol: _XSetWindowBorderPixmap
1>>>> referenced by D:\vsf.demo\application\shell\sys\linux\applets\nanox\raw\src\nx11\SetAttributes.c:16
1>>>> vsf_demo\Debug/__sub0/__sub1/__sub2/__sub3/....\application\shell\sys\linux\applets\nanox\raw\src\nx11\SetAttributes.obj:(_XChangeWindowAttributes)
1>
1>lld-link : error : undefined symbol: _XSetWindowColormap
1>>>> referenced by D:\vsf.demo\application\shell\sys\linux\applets\nanox\raw\src\nx11\SetAttributes.c:30
1>>>> vsf_demo\Debug/__sub0/__sub1/__sub2/__sub3/....\application\shell\sys\linux\applets\nanox\raw\src\nx11\SetAttributes.obj:(_XChangeWindowAttributes)

Solution:
None, I can not find XSetWindowBorderPixmap and XSetWindowColormap implementation.
I simply remove related lines.

works well with fixes above
515ad999967317445af5b5e9bb23c395
3efd92fa0ea9acb7ef218677e0eac42c_720

@ghaerr
Copy link
Owner

ghaerr commented Sep 3, 2024

Hi @versaloon, Thanks for this information. I've been a bit busy on another project to response, but I hope to look into this further soon.

Thank you!

@versaloon
Copy link
Author

Hi @versaloon, Thanks for this information. I've been a bit busy on another project to response, but I hope to look into this further soon.

Thank you!

I can create a pull request for common compile problems, but I don't know how to add XSetWindowBorderPixmap and XSetWindowColormap.

And I find some other BUGs, for example, in src/drivers/keymap_standard.h, o and p are both mapped to o. I can create a pull request for these BUGs I found when I port and use nanox.

@ghaerr
Copy link
Owner

ghaerr commented Sep 16, 2024

Hello @versaloon,

Thank you for your bug reports and offer to provide fixes via PRs :) Yes, I would welcome that, but because of the potential differences (explained in more detail below), I suggest sending sequences of smaller PRs with possibly only one bug fix each. That will allow quick commit when possible, and discussion on other when needed without holding back the entire stream.

For fixes pertaining to Nano-X/Microwindows internals, such as SCREEN_WIDTH ifdefs or (void *) additions, these are pretty straightforward - just send them in, thank you.

For fixes related to X11 compatibility, this is a bit harder (such as the Xlib.h struct _XImage function prototype changes), as, for cross-compilation compatibility on hosts that don't have X11 installed, Nano-X has included its own version of X11 headers. These headers are likely pretty old by now and might want to be updated, but some discussion may be required as to which X11 version we ought to be supporting in Nano-X internally.

but I don't know how to add XSetWindowBorderPixmap and XSetWindowColormap.

Sometimes what is needed is just a stub function so the link works, rather than a full implementation. See the file src/nx11/stub.c; perhaps you can add these functions there. It could be complicated to add a full implementationm, as Nano-X doesn't really support per-window color maps, nor fancy automatic window borders.

Thank you!

@versaloon
Copy link
Author

Hello @versaloon,

Thank you for your bug reports and offer to provide fixes via PRs :) Yes, I would welcome that, but because of the potential differences (explained in more detail below), I suggest sending sequences of smaller PRs with possibly only one bug fix each. That will allow quick commit when possible, and discussion on other when needed without holding back the entire stream.

For fixes pertaining to Nano-X/Microwindows internals, such as SCREEN_WIDTH ifdefs or (void *) additions, these are pretty straightforward - just send them in, thank you.

For fixes related to X11 compatibility, this is a bit harder (such as the Xlib.h struct _XImage function prototype changes), as, for cross-compilation compatibility on hosts that don't have X11 installed, Nano-X has included its own version of X11 headers. These headers are likely pretty old by now and might want to be updated, but some discussion may be required as to which X11 version we ought to be supporting in Nano-X internally.

but I don't know how to add XSetWindowBorderPixmap and XSetWindowColormap.

Sometimes what is needed is just a stub function so the link works, rather than a full implementation. See the file src/nx11/stub.c; perhaps you can add these functions there. It could be complicated to add a full implementationm, as Nano-X doesn't really support per-window color maps, nor fancy automatic window borders.

Thank you!

OK, I will prepare the PR after I test all the features I want in nanox in a CortexM7 platform.

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