Copyright (c) Hyperion Entertainment and contributors.

SDK FAQ: Difference between revisions

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
Content deleted Content added
m Text replacement - "<syntaxhighlight>" to "<syntaxhighlight lang="C" line>"
 
Line 3: Line 3:
Every [[Exec_Libraries|Exec Interface]] has a pointer back to the Library which owns it. There is no need to pass the Library pointer around or provide a global Library pointer. The Interface pointer contains all you need.
Every [[Exec_Libraries|Exec Interface]] has a pointer back to the Library which owns it. There is no need to pass the Library pointer around or provide a global Library pointer. The Interface pointer contains all you need.


<syntaxhighlight>
<syntaxhighlight lang="C" line>
struct Library *base = IExec->OpenLibrary("intuition.library", 50);
struct Library *base = IExec->OpenLibrary("intuition.library", 50);
struct IntuitionIFace *IIntuition = (struct IntuitionIFace*) IExec->GetInterface(base, "main", 1, NULL);
struct IntuitionIFace *IIntuition = (struct IntuitionIFace*) IExec->GetInterface(base, "main", 1, NULL);
Line 14: Line 14:
Use the LIB_IS_AT_LEAST() macro (defined in exec/libraries.h) to determine if a Library you opened is at the minimum version and revision required.
Use the LIB_IS_AT_LEAST() macro (defined in exec/libraries.h) to determine if a Library you opened is at the minimum version and revision required.


<syntaxhighlight>
<syntaxhighlight lang="C" line>
struct Library *libBase = IExec->OpenLibrary("exec.library", 50);
struct Library *libBase = IExec->OpenLibrary("exec.library", 50);


Line 30: Line 30:


If you experiencing issues with DOS constants it is likely your code has not been updated to the newer definitions. To access the obsolete definitions add the following to your source file:
If you experiencing issues with DOS constants it is likely your code has not been updated to the newer definitions. To access the obsolete definitions add the following to your source file:
<syntaxhighlight>
<syntaxhighlight lang="C" line>
#include <dos/obsolete.h>
#include <dos/obsolete.h>
</syntaxhighlight>
</syntaxhighlight>
Line 37: Line 37:


If you see warnings like the following:
If you see warnings like the following:
<syntaxhighlight>
<syntaxhighlight lang="C" line>
Prefs.cpp:97: error: cannot convert 'Image*' to 'Object*' in argument passing
Prefs.cpp:97: error: cannot convert 'Image*' to 'Object*' in argument passing
</syntaxhighlight>
</syntaxhighlight>
Line 47: Line 47:


Starting with SDK 53.24 the [[Application Library]] interfaces, ''application'' and ''prefsobjects'', must be at version 2. That means you need to change your code to do the following:
Starting with SDK 53.24 the [[Application Library]] interfaces, ''application'' and ''prefsobjects'', must be at version 2. That means you need to change your code to do the following:
<syntaxhighlight>
<syntaxhighlight lang="C" line>
struct ApplicationIFace *IApplication = (struct ApplicationIFace *) IExec->GetInterface(appBase, "application", 2, NULL);
struct ApplicationIFace *IApplication = (struct ApplicationIFace *) IExec->GetInterface(appBase, "application", 2, NULL);
struct PrefsObjectsIFace *IPrefsObjects = (struct PrefsObjectsIFace *) IExec->GetInterface(appBase, "prefsobjects", 2, NULL);
struct PrefsObjectsIFace *IPrefsObjects = (struct PrefsObjectsIFace *) IExec->GetInterface(appBase, "prefsobjects", 2, NULL);

Latest revision as of 19:08, 26 January 2025

How do I get the Library base pointer provided an Interface pointer?

Every Exec Interface has a pointer back to the Library which owns it. There is no need to pass the Library pointer around or provide a global Library pointer. The Interface pointer contains all you need.

struct Library *base = IExec->OpenLibrary("intuition.library", 50);
struct IntuitionIFace *IIntuition = (struct IntuitionIFace*) IExec->GetInterface(base, "main", 1, NULL);

IDOS->Printf("Intuition Library pointer=%p\n", IIntuition->Data.LibBase);

How do I check for a minimum Library version and revision?

Use the LIB_IS_AT_LEAST() macro (defined in exec/libraries.h) to determine if a Library you opened is at the minimum version and revision required.

struct Library *libBase = IExec->OpenLibrary("exec.library", 50);

if ( LIB_IS_AT_LEAST(libBase, 53, 58) )
{
  IDOS->Printf("Found the correct version!\n");
}
else
{
  IDOS->Printf("Minimum version 53.58 required.\n");
}

What are all these new DOS errors I'm seeing?

If you experiencing issues with DOS constants it is likely your code has not been updated to the newer definitions. To access the obsolete definitions add the following to your source file:

#include <dos/obsolete.h>

Why am I now getting warnings related to Image/Gadget and Object pointers?

If you see warnings like the following:

Prefs.cpp:97: error: cannot convert 'Image*' to 'Object*' in argument passing

your code likely needs updating to use the proper BOOPSI types.

In BOOPSI, objects can be passed around as a pointer to type Object. When Intuition functions expect a specific type they will require it to be passed as a struct Gadget * or struct Image * in arguments. They are still BOOPSI objects but they need to be type casted. This safety mechanism is there to prevent programmers from accidentally passing incorrect BOOPSI object pointers.

What is version 2 of the Application Library interfaces?

Starting with SDK 53.24 the Application Library interfaces, application and prefsobjects, must be at version 2. That means you need to change your code to do the following:

struct ApplicationIFace  *IApplication  = (struct ApplicationIFace *)  IExec->GetInterface(appBase, "application", 2, NULL);
struct PrefsObjectsIFace *IPrefsObjects = (struct PrefsObjectsIFace *) IExec->GetInterface(appBase, "prefsobjects", 2, NULL);

The interface changes were necessary to fix API flaws. Interfaces are not backwards or forwards compatible so they must be specified precisely as well.