currently I do all my AOS-coding in a (hopefully) AOS3.x compatible way. Thus I use OpenLibrary() and CloseLibrary() in order to make use of Lib-Functions for example from asl.library, graphics.library, intuition.library, gadtools.library, diskfont.library, layers.library and so on. I'm also always set __USE_INLINE__ as a Compiler flag (-D for GCC). I don't use IFaces or sth. else special in AOS4 at all.
Now I heard that this is not really necessary since when using #define __USE_INLINE__ switch every amigaos function will be considered as old os3.x function,
without special casting like IExec->function() or IIntuition->function(), what also means that all the stuff will open automatically, without needs of open the IFaces an so on. Usually together with that -lamiga and -lauto linking libs are added.
This confuses me a little bit. I'm wondering whether it is necessry to call OpenLibrary() and CloseLibrary() in order to use Libfunctions or not when coding under AOS4 (even in old AOS3.x/68k style)?
Maybe somebody here can shed some light on this?
Many thanks in advance and
__USE_INLINE__ will take care about IFACE->function() casts, thats one deal
Added -lauto on the linking stage will take care about opening/closing of most libraryes, thats another deal.
I.e. __USE_INLINE__ itself do not mean that anything will opens automatically, but mean that no IFACE-> casts need it. And -lauto will take care about open/close libs (and can be used without __USE_INLINE__ pretty well, just with all that IFACE-> etc stuff).
Btw, sometime -lauto will not enough, and you will have errors about some functions from some libraryes: in that case you just need to add right
#include <proto/protofile.h>to code).
Also it is no harm to just open them all in code manually, and its even "preffered" to have it like this and do not use -lauto. But still, i for myself all the time use it, just because its easy. More of it, i pretty offten open half of libs manually, and half of libs via -lauto, and open some libs which will cover -lauto: thats suck and mess, but works.
Of course it is always necessary to open a particular library before you use its functions! But you can use an autoinitialization code (the link library "libauto", via the -lauto switch) to open the libraries for you.
Still I'd recommend developing a habit to always open libraries manually. Usually it doesn't take more than writing an extra sourcecode file with library opening/closing stuff which you'll simply include in every project you make.
Personally, I only use -lauto for testing or implementing an idea quickly. When my programming itch actually turns into a proper application, I always open/close resources manually.
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
If I am not wrong, with -lauto you can't set the minimum version of the library your program needs, so in case a user has an older library a requester will appear.
That is the case with autoinit code generated by the current idltool.
It doesn't have to be that way though as f.e. with fd2pragma generated m68k library autoinit code you can set a minimum library version by simply defining a variable in your code:
unsigned long _ExpatBaseVer = 4;
If you don't define this variable one will be linked in for you with a value of 0.
Also nothing is stopping from checking the version after the fact by using the library base pointer. As a matter of fact if you need to check for a minimum revision as well as version then you have to it this way.