Is it possible to make an enum public, in a module where the default is private?
module mod
private
enum, (public,) bind(c) !Doesn't work
enumerator(, public) :: ENUM1, ENUM2,... !Doesn't work
end enum
end module
I want to keep the module data private by default but want the enums to be public without having to list them individually like this:
public :: ENUM1, ENUM2,... !Works
I understand that enums are just integer parameters so I'm curious if it's possible to do it for all of them at once.
What you are trying to do does not conform the syntax rules from Fortran 2008 4.6.1., therefore, it is not possible to insert the public attributes in the enumeration definition.
There is also no way to put the enumerators in the public statement as a group, you must list each of them.
The enumerations were added to Fortran more or less only for C interoperability (note the obligatory bind(c)) and do not fit the rest of the language that well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With