Using optional arguments

Using optional arguments

I am getting compiler warning
"Routine PARSETAG called with different number and/or type of
actual arguments in earlier call - C attribute required if intended"
on a situation like the following:

integer function f(a, b, c, d) result(u)
integer a
integer b
integer c
integer, optional :: d
u = 0
end function f

integer function g() result(v)
integer, external :: f
v = f(1,2,3)
end function g

integer function h() result(w)
integer, external :: f
w = f(1,2,3,4)
end function h

The issue seems to be in the proper usage of optional arguments.
How do I resolve this?

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If a routine has OPTIONAL arguments, an explicit interface must be visible to the caller.


Retired 12/31/2016

Add a trailing comma on the call in g() so that your number of placeholders is consistent.


Leave a Comment

Please sign in to add a comment. Not a member? Join today