Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
84 user(s) are online (41 user(s) are browsing Forums)

Members: 0
Guests: 84

more...

Headlines

 
  Register To Post  

(1) 2 »
LibNode, iobsoletes, inlines vs protos
Home away from home
Home away from home


See User information
Forced with some strange problem, maybe someone can help me. Test code:

#define __USE_INLINE__

#include <proto/intuition.h>
#include <stdio.h>

main()
{
   if(
IntuitionBase->LibNode.lib_Version>38) {
        
printf("version >38\n");
   }
   else {
        
printf("version <38\n");
   }
}


And on compiling stange i have:

Quote:

error: 'struct Library' has no member named 'LibNode'.


I am sure it should be something easy like some casting or so, but just stuck with it a bit. I even do search on all LibNode entryes in whole SDK, and include all includes where find out this: no luck. As well as trying to case IntuitionBase as (struct Library *): no luck as well.


Edited by kas1e on 2013/3/22 6:44:43
Edited by kas1e on 2013/3/22 6:48:11
Edited by kas1e on 2013/3/22 6:50:01
Edited by kas1e on 2013/3/22 12:06:54
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode check
Home away from home
Home away from home


See User information


IntuitionBase * as implicitly declared in that minimal program is a struct Library *, clearly a struct Library * has no member LibBase as that is the lib base.....
#include <proto/intuition.h>
#include <stdio.h>


main()
{
struct IntuitionBase intBase  = (struct IntuitionBase  *)IntuitionBase;

   if(
intBase->LibNode.lib_Version>38) {
        
printf("version >38n");
   }
   else {
        
printf("version <38n");
   }
}


would work if that's the best way would depend a lot on what context you were using it in.




Go to top
Re: LibNode check
Just can't stay away
Just can't stay away


See User information
@kas1e

In AmigaOS 4.x the global library base variables are by default all defined as pointers to struct Library rather than some base variables using more specific types like struct ExecBase, IntuitionBase, ...

If you want the old behavior for compatibility with older code you just need to add -D__USE_BASETYPE__ to the compiler flags.

Go to top
Re: LibNode check
Home away from home
Home away from home


See User information
@Andy
Thats for dopus5.library port, which is used a lot that LibNode stuff in different parts, like:

if (GfxBase->LibNode.lib_Version>=39
if (
IntuitionBase->LibNode.lib_Version>=39)


Those ones originally declared in dopus code as:

struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;


But for os4 build i comment them out, as gcc scream about:

Quote:

data.c:32: error: conflicting types for 'IntuitionBase'
/usr/local/amiga/ppc-amigaos/SDK/include/include_h/proto/intuition.h:40: note: previous declaration of 'IntuitionBase' was here
data.c:33: error: conflicting types for 'GfxBase'
/usr/local/amiga/ppc-amigaos/SDK/include/include_h/proto/graphics.h:57: note: previous declaration of 'GfxBase' was here


And so i need to keep original code as much as possible untouched, just to make it compiles on os4 with use_inline. I can of course add casts + ifdefs, but better to keep original code at first native compile as much as possible.


@salas00
Thanks ! -D__USE_BASETYPE__ did the trick

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode check and some ioobsoletes
Home away from home
Home away from home


See User information
@all
I also meet in code with some obsolete on os4 intuition defines such as:

STRINGCENTER
STRINGRIGHT
STRINGLEFT

They all in the intuition/iobsolete.h , but including such a file didn't help. I also tryed to set #define INTUITION_PRE_V36_NAMES , as well as use-D__INTUITION_PRE_V36_NAMES__ : no luck. Is there another switch or the only way is to copy+paste defines to code ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode check and some ioobsoletes
Just popping in
Just popping in


See User information
Quote:
They all in the intuition/iobsolete.h , but including such a file didn't help. I also tryed to set #define INTUITION_PRE_V36_NAMES , as well as use-D__INTUITION_PRE_V36_NAMES__ : no luck. Is there another switch or the only way is to copy+paste defines to code ?


The symbol must be named "INTUITION_PRE_V36_NAMES" and not "__INTUITION_PRE_V36_NAMES__". And you must define it before including intuition/iobsoletes.h.

Go to top
Re: LibNode check and iobsoletes
Home away from home
Home away from home


See User information
@Thore
Still nope, i have:

#ifdef __amigaos4__
#define INTUITION_PRE_V36_NAMES
#include <intuition/iobsolete.h>
#endif

And have undefs. If i just do:

#ifdef __amigaos4__
#define STRINGLEFT GACT_STRINGLEFT
#define STRINGCENTER GACT_STRINGCENTER
#define STRINGRIGHT GACT_STRINGRIGHT
#endif

Then it works

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode check and iobsoletes
Just popping in
Just popping in


See User information
Quote:
#ifdef __amigaos4__
#define INTUITION_PRE_V36_NAMES
#include <intuition/iobsolete.h>
#endif


intuition/iobsolete.h is already included by several other include files, i.e. intuition/screens.h. Hence most probably it has been included already at the time you do it explicitly and therefore your own definition of INTUITION_PRE_V36_NAMES comes a bit too late. Better add -DINTUITION_PRE_V36_NAMES to the CFLAGS definition in your Makefile to make sure that the symbol is always defined.

Go to top
Re: LibNode check and iobsoletes
Home away from home
Home away from home


See User information
@Thore
Quote:

Hence most probably it has been included already at the time you do it explicitly and therefore your own definition of INTUITION_PRE_V36_NAMES comes a bit too late.

Right, i just put it at very top of file and all going well (and -DINTUITION_PRE_V36_NAMES works as well). Thanks

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode check and iobsoletes
Just popping in
Just popping in


See User information

if you want a version free working in 1.3/3.1/4.x... just keep in mind that IntuitionBase is now a struct Library* and was a struct IntuitionBase* in ancient times.

main()
{
if(((struct Library*)IntuitionBase)->lib_Version>38) {
printf("version >38n");
}
else {
printf("version <38n");
}
}

Go to top
Re: LibNode check and iobsoletes
Home away from home
Home away from home


See User information
@Gilloo
Thanks !

I assume the same code can works on mos/aros as well, so i can safely avoid ifdefs and just change all versions check on such kind ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode check and iobsoletes
Home away from home
Home away from home


See User information
@Gilloo
What about:

Quote:

strcpy(env->font_name[FONT_DIRS],GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name);
env->font_size[FONT_DIRS]=GfxBase->DefaultFont->tf_YSize;


os4 gcc says:

Quote:

error: 'struct Library' has no member named 'DefaultFont'
error: 'struct Library' has no member named 'DefaultFont'


Is there also some os1/3/4 way ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode check and iobsoletes
Just popping in
Just popping in


See User information
Same technique: casting! (it works on all C/C++ compilers :) )

strcpy(env->font_name[FONT_DIRS],((struct GfxBase *)GfxBase)->DefaultFont->tf_Message.mn_Node.ln_Name) ;

env->font_size[FONT_DIRS]=((struct GfxBase *)GfxBase)->DefaultFont->tf_YSize ;

Go to top
Re: LibNode check and iobsoletes
Home away from home
Home away from home


See User information
@Gilloo
Thanks, casting rokz.

Btw, maybe you also aware of such problem:

For os3 build we have done some inlines of some functions, like:

#ifndef _INLINE_MUSIC_H
#define _INLINE_MUSIC_H

#ifndef CLIB_MUSIC_PROTOS_H
#define CLIB_MUSIC_PROTOS_H
#endif

#ifndef __INLINE_MACROS_H
#include <inline/macros.h>
#endif

#include <exec/types.h>

#ifndef MUSIC_BASE_NAME
#define MUSIC_BASE_NAME MUSICBase
#endif

#define PlayModule(par1, last) \
    
LP2(0x1eWORDPlayModulechar *, par1a0BOOLlastd0\
    
MUSIC_BASE_NAME)

#define StopModule() \
    
LP0NR(0x24StopModule\
    
MUSIC_BASE_NAME)

#define IsModule(last) \
    
LP1(0x2aWORDIsModulechar *, lasta0\
    
MUSIC_BASE_NAME)

#define FlushModule() \
    
LP0NR(0x30FlushModule\
    
MUSIC_BASE_NAME)

#define ContModule() \
    
LP0NR(0x36ContModule\
    
MUSIC_BASE_NAME)

#define SetVolume(last) \
    
LP1NR(0x3cSetVolumeWORDlasta0\
    
MUSIC_BASE_NAME)

#define PlayFaster() \
    
LP0NR(0x42PlayFaster\
    
MUSIC_BASE_NAME)

#define PlaySlower() \
    
LP0NR(0x48PlaySlower\
    
MUSIC_BASE_NAME)

#define TempoReset() \
    
LP0NR(0x4eTempoReset\
    
MUSIC_BASE_NAME)

#endif /*  _INLINE_MUSIC_H  */


os4 do not like inlines, but want protos instead. it is possible to make proto includes which will not ask on linking stage for linking stub libs, and will works/compiles and on os3 and on os4 the same by the same code ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: LibNode, iobsoletes, inlines vs protos
Just popping in
Just popping in


See User information
in principle, a source code should start like that:

/* structs and constants */
#include <exec/types.h>

/* prototypes */
#include <clib/alib_protos.h>
#include <proto/exec.h>

/* functions */
/* main */

proto directories link pragmas or inlines with the source code.
If you want to make inlines, hide this in proto directory.
For your case, I suggest you to make a
proto/music.h for each system or compiler or architecture.

Go to top
Re: LibNode check and iobsoletes
Just can't stay away
Just can't stay away


See User information
@kas1e

You can use fd2pragma to generate proto files that include the correct inline/pragma file type depending on what compiler is being used.

I use fd2pragma with special=38 argument to generate my proto/ files for m68k compiling and they end up looking like this:

#ifndef _PROTO_BZ2_H
#define _PROTO_BZ2_H

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif
#if !defined(CLIB_BZ2_PROTOS_H) && !defined(__GNUC__)
#include <clib/bz2_protos.h>
#endif

#ifndef __NOLIBBASE__
extern struct Library *BZ2Base;
#endif

#ifdef __GNUC__
#ifdef __AROS__
#include <defines/bz2.h>
#else
#include <inline/bz2.h>
#endif
#elif defined(__VBCC__)
#include <inline/bz2_protos.h>
#else
#include <pragma/bz2_lib.h>
#endif

#endif    /*  _PROTO_BZ2_H  */

Go to top
Re: LibNode, iobsoletes, inlines vs protos
Not too shy to talk
Not too shy to talk


See User information
Hello kas1e

libnode is used only for CREATING a custom library

Something like

struct mycustomlib{
struct libray libnode;
ULONG myprivatedata;
}

So it have a standard library struct = libnode
AND private data

If you are not in a library header (and you dont use a struct like mycustomlib) then you can remove libnode
and use (say) intuitionbase->version

Alain

see stormmesa2010 sources

Go to top
Re: LibNode, iobsoletes, inlines vs protos
Supreme Council
Supreme Council


See User information
Your compile error with regard to library base types appears to be due to a missing -nostartfiles compile and link option.

You should not be using the C library startup routines in a library.

Simon

Comments made in any post are personal opinion, and are in no-way representative of any commercial entity unless specifically stated as such.
----
http://codebench.co.uk
Go to top
Re: LibNode, iobsoletes, inlines vs protos
Quite a regular
Quite a regular


See User information
Inline protos are OK, as long as they are defined in a way that prevents clashes between modules.

If you say "INLINE <type> MyFunc()" in a global header that all modules can read, then each module will export the name MyFunc() and you'll get multiple definitions. You have to change the inline definition to:

static INLINE <type> MyFunc(...)

Put that in your global proto header and no module will export the address to conflict with others.

cheers
tony
Go to top
Re: LibNode, iobsoletes, inlines vs protos
Home away from home
Home away from home


See User information
@Gilloo,Salas00, tonyw

The real problem with inlines/protos looks like this:

I need to use any kind of includes, so they will works _without_ stub libs. Thats very important: to have those includes done in a way to not have any undefs on linking.

I.e. i have in code PlayModule()/IsModule()/etc function which come from some music library and which uses in the library on which i works, like this:
// Open music library?
if(MUSICBase=OpenLibrary("dopus5:libs/inovamusic.library",0))
{
short ret;

// Ask library
ret=IsModule(handle->name);

// Close library
CloseLibrary(MUSICBase);
 
.....


So for that originally on sasc #pragmas are used, like this:

#pragma libcall MUSICBase PlayModule   1e 0802
#pragma libcall MUSICBase StopModule   24 0
#pragma libcall MUSICBase IsModule     2a 801
#pragma libcall MUSICBase FlushModule  30 0
#pragma libcall MUSICBase ContModule   36 0
#pragma libcall MUSICBase SetVolume    3c 801
#pragma libcall MUSICBase PlayFaster   42 0
#pragma libcall MUSICBase PlaySlower   48 0
#pragma libcall MUSICBase TempoReset   4e 0


For os3 build , we just use fd2pragma and generate inlines instead of pragmas (so they works on 68k gcc):

#ifndef _INLINE_MUSIC_H
#define _INLINE_MUSIC_H

#ifndef CLIB_MUSIC_PROTOS_H
#define CLIB_MUSIC_PROTOS_H
#endif

#ifndef __INLINE_MACROS_H
#include <inline/macros.h>
#endif

#include <exec/types.h>

#ifndef MUSIC_BASE_NAME
#define MUSIC_BASE_NAME MUSICBase
#endif

#define PlayModule(par1, last) \
    
LP2(0x1eWORDPlayModulechar *, par1a0BOOLlastd0\
    
MUSIC_BASE_NAME)

#define StopModule() \
    
LP0NR(0x24StopModule\
    
MUSIC_BASE_NAME)

#define IsModule(last) \
    
LP1(0x2aWORDIsModulechar *, lasta0\
    
MUSIC_BASE_NAME)

#define FlushModule() \
    
LP0NR(0x30FlushModule\
    
MUSIC_BASE_NAME)

#define ContModule() \
    
LP0NR(0x36ContModule\
    
MUSIC_BASE_NAME)

#define SetVolume(last) \
    
LP1NR(0x3cSetVolumeWORDlasta0\
    
MUSIC_BASE_NAME)

#define PlayFaster() \
    
LP0NR(0x42PlayFaster\
    
MUSIC_BASE_NAME)

#define PlaySlower() \
    
LP0NR(0x48PlaySlower\
    
MUSIC_BASE_NAME)

#define TempoReset() \
    
LP0NR(0x4eTempoReset\
    
MUSIC_BASE_NAME)

#endif /*  _INLINE_MUSIC_H  */


So, we have no undefs on linking, as well as i have it compiles fine with gcc. But it is for 68k, and there all those 68k registers, and so on, and of course that kind of inlines will not works when i will try to compile them for os4. More of it, gcc compiler says to me on those inlines (even if we will not take in account 68k registers):

Quote:

error: #error Include <proto/> header files, not <inline/> header files in OS4.


What force me to make new include files, which will give me no undefs on linking stage, and will works on os4 (so protos and not inlines). And so, thats what i want to do:

Will be cool to make a protos which will works and on os3 and on os4 (so that will be easy then later and for aros/mos). It is possible ? Maybe with using of SDI ? If so, how will looks like that string to make it works on gcc for os3/os4 ?:

#define PlayModule(par1, last) \
    
LP2(0x1eWORDPlayModulechar *, par1a0BOOLlastd0\
    
MUSIC_BASE_NAME)


Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project