View previous topic :: View next topic |
Author |
Message |
wahorger

Joined: 13 Oct 2014 Posts: 1257 Location: Morrison, CO, USA
|
Posted: Tue Apr 07, 2020 12:25 am Post subject: Compiler issue? |
|
|
In my code, I had inadvertently place a CALL to a WINAPI function (showwindow), rather than a function reference. I included "USE MSWIN" in the function that referenced the API.
There was no error or warning. The effect on the code was to make it all wonky (only way I can describe it). The callbacks did not work for the %rd it was tied to, and only clicking on the upper right "X" would close the window.
I am wondering if perhaps, somewhere, I have something similar that is making my use of HELP all messed up.
But, it seems like the compiler should find this kind of problem. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue Apr 07, 2020 8:15 am Post subject: |
|
|
Can you provide a short demo program that illustrates the problem? |
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1257 Location: Morrison, CO, USA
|
Posted: Tue Apr 07, 2020 2:17 pm Post subject: |
|
|
The following code will generate one warning (i_log is never used), no errors.
Code: | winapp
program cmain
use mswin
logical :: i_log
i_log = showwindow(0,SW_HIDE)
end
integer function button1()
use mswin
call showwindow(0,SW_RESTORE)
button1 = 1
return
end
|
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Tue Apr 07, 2020 2:27 pm Post subject: |
|
|
A call to ShowWindow(0,SW_HIDE) (with zero as the first argument) might be unfortunate. I don't know what it might do and I would not want to find out by testing it. A NULL value for the HWND might even default to the desktop. |
|
Back to top |
|
 |
wahorger

Joined: 13 Oct 2014 Posts: 1257 Location: Morrison, CO, USA
|
Posted: Tue Apr 07, 2020 2:43 pm Post subject: |
|
|
Paul, this only shows no compiler error is generated.
I have been working on the "wonky" case, but could not replicate with a short example. I'll try a slight change to see if providing a real handle could help show the issue. |
|
Back to top |
|
 |
DietmarSiepmann
Joined: 03 Jun 2013 Posts: 279
|
Posted: Tue Apr 07, 2020 5:54 pm Post subject: |
|
|
Paul, wahorger,
I observed this, too, for I use the SALFORD compiler and INTEL 64 bit compiler for the same code base: the INTEL 64 bit compiler creates an error, if using call with respect to a function, whereas the SALFORD compiler does not complain.
Dietmar |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8210 Location: Salford, UK
|
Posted: Wed Apr 08, 2020 8:12 am Post subject: |
|
|
Maybe I missed the point here.
If you CALL a function like ShowWindow, that is a FUNCTION rather than a SUBROUTINE then FTN95 does not complain. At run time the returned value is simply discarded.
You will find this is also true for the C++ compiler SCC but here it is clearly accepted in the C++ Standard.
I suspect that the Fortran Standard makes no comment on this. If it does then please let me know. |
|
Back to top |
|
 |
|