#pragma libcall on AROS

serk118uk · 402

serk118uk

  • Member
  • ***
    • Posts: 129
    • Karma: +60/-0
on: October 27, 2021, 11:47:39 AM
Hi ppl,

I have looked at aros tree examples codes for help and to be fair i coulld't understand how #pragma libcall made on on AROS,
mostly used as

#ifndef __AROS__
#pragma libcall AmIDE_API_Base AmIDE_API_GetClass 1e 0
#endif

but than how its done in AROS, gcc dont complain while compiling, i still get AmIDE_API_GetClass missing at main compile so "#pragma libcall AmIDE_API_Base AmIDE_API_GetClass 1e 0" not AROS friendly i guess ..

Lets Build Not Destroy...


deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1001
    • Karma: +103/-0
Reply #1 on: October 27, 2021, 11:56:24 AM
I'm not familiar with this notation. What you are trying to achieve?



serk118uk

  • Member
  • ***
    • Posts: 129
    • Karma: +60/-0
Reply #2 on: October 27, 2021, 01:53:25 PM
What you are trying to achieve?

deadwood remember the plugin/module we compiled other day (thanks to your help) and now
i am actualy trying to load that plugin/module at main.c

Function AmIDE_API_GetClass is in sasc.module.c and than defined in 

modules/api/clib/amide_api_protos.h
modules/api/pragmas/amide_api_pragmas.h
modules/api/proto/amide_api.h

and LoadModules function calls that function from main.c

i have not made lib calls before so i am bit lost..

main.c
Code: [Select]
BOOL LoadModules(struct FileInfoBlock *fib,  STRPTR pattern)
{
  char modulepath[256];
  struct IClass *mod_class;
  struct str_modules *module;

  #ifdef DEBUG
  DEBUG_MAKRO
  #endif

  sprintf(modulepath, "modules/%s", (STRPTR) &(fib->fib_FileName));

  if(MatchNoCase(modulepath, pattern) == 1)
  {
    // Speicher für die Struktur holen
    module = (struct str_modules *)calloc(1, sizeof(struct str_modules));
    if(!module) return(TRUE);

    // Den Pfad des modules nun in die Struktur schreiben
    strcpy(module->module_path, modulepath);

    // Jetzt die Library öffnen
    module->libbase = OpenLibrary(modulepath, 0);
    if(!module->libbase) return(TRUE);

    // LibBase umkopieren
    AmIDE_API_Base = module->libbase; 

    // Klasse holen

    mod_class = AmIDE_API_GetClass();     //<<<<<this is where its used
   
    if(!mod_class) return(TRUE);

    // Objekt erzeugen
    module->lib_object = NewObject(mod_class, NULL, TAG_DONE, NULL);
    if(!module->lib_object) return(TRUE);

    // Jetzt die Struktur an die Liste hängen
    DoMethod(LS_AmIDE_Modules, MUIM_List_InsertSingle, module, MUIV_List_Insert_Bottom, TAG_DONE);
  }

  return(TRUE);
}

Lets Build Not Destroy...


deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1001
    • Karma: +103/-0
Reply #3 on: October 27, 2021, 02:23:50 PM
Ok, I understand. In case of AROS it is best to use portable macros to make these calls. I'm now writing from memory so there can be bugs:

Code: [Select]
mod_class =AROS_LC0(void *, AmIDE_API_GetClass,
        struct Library *, (AmIDE_API_Base), 5, AmIDE_API    );

Code: [Select]
#include <aros/libcall.h>



serk118uk

  • Member
  • ***
    • Posts: 129
    • Karma: +60/-0
Reply #4 on: October 27, 2021, 02:42:40 PM
Ok, I understand. In case of AROS it is best to use portable macros to make these calls. I'm now writing from memory so there can be bugs:

Code: [Select]
mod_class =AROS_LC0(void *, AmIDE_API_GetClass,
        struct Library *, (AmIDE_API_Base), 5, AmIDE_API    );

Code: [Select]
#include <aros/libcall.h>

Amazing you are, worked thanks

Lets Build Not Destroy...


deadwood

  • AROS Developer
  • Legendary Member
  • *****
    • Posts: 1001
    • Karma: +103/-0
Reply #5 on: October 27, 2021, 03:25:13 PM
Lucky shot :D

Note that argument '5' in the macro defines the position of function. First user function has position 5.