Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

PRIVATE and cascading USE

$
0
0

Hello,

I have stumbled about a non intuitive (at least for me) feature fo the Intel Compiler (2016 and 2017) which I am not sure is standard compliant or not.

If I have a type TT defined (as public) in a module M1, and that I do a USE M1 in a module M2, the type is then visible and useable in the module M2. This is clear to me. But if the module M2 does not use the PRIVATE keyword, using of M2 seems also to imply USE M1. Is it a behavior documented in the standard?

Here some simple code showing what I mean:

program Console
  use m2
  implicit none
  type(TT) :: var ! Why can I use TT without a USE m1 ???
  print *, 'Hello World'
end program

module m2
  use m1
  implicit none
  ! module is public
end module
 
module m1
  implicit none
  private
  type, public :: tt
  end type
end module
  

 

Zone: 


Viewing all articles
Browse latest Browse all 5691

Trending Articles