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

mingw64 compiler warning in wincon/pdcscrn #251

Open
GitMensch opened this issue Nov 29, 2022 · 4 comments
Open

mingw64 compiler warning in wincon/pdcscrn #251

GitMensch opened this issue Nov 29, 2022 · 4 comments

Comments

@GitMensch
Copy link
Collaborator

../wincon/pdcscrn.c: In function 'PDC_scr_open':
../wincon/pdcscrn.c:484:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, struct _CONSOLE_SCREEN_BUFFER_INFOEX *)' {aka 'int (*)(void *, struct _CONSOLE_SCREEN_BUFFER_INFOEX *)'} [-Wcast-function-type]
  484 |         (GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
      |         ^
../wincon/pdcscrn.c:487:9: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)(void *, struct _CONSOLE_SCREEN_BUFFER_INFOEX *)' {aka 'int (*)(void *, struct _CONSOLE_SCREEN_BUFFER_INFOEX *)'} [-Wcast-function-type]
  487 |         (SetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
      |         ^
@Bill-Gray
Copy link
Owner

I've known about this one for a while now. I've tried various ways of declaring that function, but always get this warning. It's the reason -Werror is not enabled on WinCon.

@GitMensch
Copy link
Collaborator Author

That should be able to be silenced by the following, I guess:

-         (GetConsoleScreenBufferInfoExFn)GetProcAddress(h_kernel,
+         (GetConsoleScreenBufferInfoExFn)(void *)GetProcAddress(h_kernel,

@Bill-Gray
Copy link
Owner

Hmmm... that gets me the warnings shown below. Are you seeing a clean build with this change?

If you are, I think I'll add it and commit it, because (1) it at least fixes the warnings on some platform(s) and (2) a pedantic warning is at least a step forward from a plain "ordinary" warning.

../wincon/pdcscrn.c: In function ‘PDC_scr_open’:
../wincon/pdcscrn.c:484:41: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  484 |         (GetConsoleScreenBufferInfoExFn)(void *)GetProcAddress(h_kernel,
      |                                         ^
../wincon/pdcscrn.c:484:9: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
  484 |         (GetConsoleScreenBufferInfoExFn)(void *)GetProcAddress(h_kernel,
      |         ^
../wincon/pdcscrn.c:487:41: warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic]
  487 |         (SetConsoleScreenBufferInfoExFn)(void *)GetProcAddress(h_kernel,
      |                                         ^
../wincon/pdcscrn.c:487:9: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
  487 |         (SetConsoleScreenBufferInfoExFn)(void *)GetProcAddress(h_kernel,
      |         ^

@GitMensch
Copy link
Collaborator Author

Are you seeing a clean build with this change?

Nope, that was just an educated guess.

More guessing (I'd try in the order simple to complicate):

(void *(*)(void *, struct _CONSOLE_SCREEN_BUFFER_INFOEX *)) or (void *(*)(void *, void *)) or simpler (void *(*)())

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