- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
Maybe it's an oversight or maybe I'm missing some reasoning, but shouldn't the following code compile properly?
use ISO_C_BINDING
implicit none
interface
pure function fnmatch(pattern, string, flags) bind(C, NAME = 'fnmatch')
import
integer(C_INT) :: fnmatch
character(KIND = C_CHAR), intent(in) :: pattern(*), string(*)
integer(C_INT), value :: flags
end function
end interface
print *, match('*.f90', 'test.f90')
print *, match('*.f90', 'test.c')
contains
pure function match(pattern, string) result(res)
integer(C_INT) :: res
character(*), intent(in) :: pattern, string
res = fnmatch(f_c_string(pattern), f_c_string(string), 0_c_int)
end function
end
If I remove the "pure" prefix from the "match" function, the code compiles and runs correctly on linux ---but I have a hard time switching from my custom (and pure) "f2cstring" function to the standard one.
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page