forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compiler issue?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
wahorger



Joined: 13 Oct 2014
Posts: 825
Location: Morrison, CO, USA

PostPosted: Tue Apr 07, 2020 12:25 am    Post subject: Compiler issue? Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6564
Location: Salford, UK

PostPosted: Tue Apr 07, 2020 8:15 am    Post subject: Reply with quote

Can you provide a short demo program that illustrates the problem?
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 825
Location: Morrison, CO, USA

PostPosted: Tue Apr 07, 2020 2:17 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6564
Location: Salford, UK

PostPosted: Tue Apr 07, 2020 2:27 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 825
Location: Morrison, CO, USA

PostPosted: Tue Apr 07, 2020 2:43 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
DietmarSiepmann



Joined: 03 Jun 2013
Posts: 241

PostPosted: Tue Apr 07, 2020 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 6564
Location: Salford, UK

PostPosted: Wed Apr 08, 2020 8:12 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
John-Silver



Joined: 30 Jul 2013
Posts: 1450
Location: Aerospace Valley

PostPosted: Thu Apr 09, 2020 8:14 pm    Post subject: Reply with quote

Paul clarified that:
Quote:
...then FTN95 does not complain. At run time the returned value is simply discarded


... so, the function is executed but with no return value.
Shouldn't this be corrected because although the function is executed you might have coded something which depends on the return value ! ?
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group