Closed awvwgk closed 2 years ago
No we don't currently have that. We could add it though. I do like the idea.
Currently the .VERSION
file has the version number. That is mainly used for the doc deployment and isn't read by the code.
Maybe we can use preprocessing to include that file in a string parameter?
Note that module variables are accessed at compile time not at runtime. Using the version support from https://github.com/jacobwilliams/json-fortran/commit/8a33d9bb60fd681aaf62c31a290214ee6b3c6604 allows to check which version of json-fortran a project was compiled against, however not which version is currently used. For static linking those cases are identical, for dynamic linking those don't have to match.
I don't fully understand the concern. Are you saying somebody might use a newer shared lib with an older set of the .mod files? I would say they shouldn't do that.
Indeed, this is a realistic application as long as you allow setting BUILD_SHARED_LIBS=ON
for CMake. Obviously, one has to be careful about compatible versions, but I'm basically using most Fortran libraries via dynamic linking and tight version pins without much problems so far. Having the possibility to query which actual version is used is useful in this scenario.
I'm still not sure I get it. If you use a fortran library that is exporting modules, you need the library and the mod files. There's no guarantee that using a newer library with old mod files is going to work at all. Is this what you are doing? I would not recommend it!
In any event, what about the function version I just committed?
Thanks, looks great.
There's no guarantee that using a newer library with old mod files is going to work at all. Is this what you are doing? I would not recommend it!
Got it, I'll be careful ;). I'm mostly using dynamic linking in package manager or environment manager controlled setups to avoid hours of recompiling dozens of interdependent libraries and executables. Of course I'm going for static linking if I can't have a package manager handling the version constraints and ensuring compatibility.
Is there a way to query the version of json-fortran at runtime? Something along the lines of
Would be useful for projects which depend on json-fortran and want to report which version they are using at runtime.