Silverfrost Forums

Welcome to our forums

Compiler issue?

6 Apr 2020 11:25 #25155

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.

7 Apr 2020 7:15 #25156

Can you provide a short demo program that illustrates the problem?

7 Apr 2020 1:17 #25162

The following code will generate one warning (i_log is never used), no errors.

	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
7 Apr 2020 1:27 #25164

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.

7 Apr 2020 1:43 #25167

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.

7 Apr 2020 4:54 #25170

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

8 Apr 2020 7:12 #25171

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.

Please login to reply.