Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making an enum public

Tags:

fortran

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.

like image 941
Exascale Avatar asked Oct 22 '25 06:10

Exascale


1 Answers

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.

like image 197
Vladimir F Героям слава Avatar answered Oct 26 '25 00:10

Vladimir F Героям слава