English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 21 August 2022, 10:31   #1
Jami
Bruno
 
Jami's Avatar
 
Join Date: Aug 2020
Location: Nantes / France
Posts: 111
Question VBCC and SysBase in aos68km target

There is something that I do not understand and that seems weird regarding the SysBase declaration.


I am using :
  • VBCC V0.9h patch3 under win10
  • aos68km target (which use minimal startup code). This code should set up SysBase, as stated in VBCC 0.9h manual at § 14.5.6 Minimal Startup
  • AmigaOS 3.2 NDK3.2R4

• Compiling the code at the end of my post which use SysBase with those parameter works fine :
VC +aos68km -v Librairies.c -o Librairies-inline -I../lib/NDK3.2R4/Include_H


• However, when disabling inline calls, strangely SysBase is undeclared:
VC +aos68km -v Librairies.c -lamiga -o Librairies-no-inline-err -D_NO_INLINE -I../lib/NDK3.2R4/Include_H


->VPrintf("SysBase->SoftVer=%u\n", & (SysBase->SoftVer));
error 82 in line 12 of "Librairies.c": unknown identifier <SysBase>


Defining
_NO_INLINE
prevents SysBase to be set up.
It seems that proto\exec.h of AmigaOS NDK does not define SysBase when
_NO_INLINE
is defined.

• It builds fine if I explicitly list VBCC target headers file before AmigaOS NDK 3.2 headers when calling VC :
 VC +aos68km -v Librairies.c -lamiga -o Librairies-no-inline-ok -D_NO_INLINE -Ibin/targets/m68k-amigaos/include -I../lib/NDK3.2R4/Include_H



Is there another better way to force VC frontend to use VBCC target include file before NDK include files when calling vbccm68k ?
I mean from the command line. (without altering VC config file).


Librairies.c :
Code:
#include <proto/exec.h>
#include <proto/dos.h>

struct DosLibrary *DOSBase;

int main()
{
   DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 0);
  
   if (DOSBase)
   {
       VPrintf("SysBase->SoftVer=%u\n", & (SysBase->SoftVer));
 
       CloseLibrary((struct Library *)DOSBase);
   }

   return 0;
}

Last edited by Jami; 21 August 2022 at 18:19.
Jami is offline  
Old 22 August 2022, 00:27   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
What you observe here is that <proto/exec.h> declares the execbase library entries such that SysBase is taken from address 4, and for that reason does not need SysBase as external symbol. If it is not declared, no harm is done for calling exec functions - except that they are slower than necessary because the code has now to get SysBase from chip RAM (or even worse, has to emulate the access).
Thomas Richter is offline  
Old 22 August 2022, 17:07   #3
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Hmm... no, I don't think this is what Jami means. You can see that with all NDK3.2 proto-headers. Not only for
proto/exec.h
. For example
proto/graphics.h
:
Code:
#ifdef _NO_INLINE

#include <clib/graphics_protos.h>

#else

/****************************************************************************/

#ifndef __NOLIBBASE__

#ifndef GRAPHICS_GFXBASE_H
#include <graphics/gfxbase.h>
#endif /* GRAPHICS_GFXBASE_H */

extern struct GfxBase * GfxBase;
#endif /* __NOLIBBASE__ */
Seems that the official proto headers do not declare the base with
_NO_INLINE
, which is different to the proto headers coming with vbcc. I wouldn't call that a big problem, but maybe I should have insisted in vbcc-compatibility when talking with Olaf Barthel about the new NDK.

NDK3.9 doesn't have that problem, but it also doesn't support
_NO_INLINE
.

Usually the problem shouldn't occur, because you should set up your vbcc config file for aos68k (and aos68km) in a way that the vbcc-headers always have priority over the NDK-headers (the Installer for AmigaOS does that automatically).

To be on the safe side, and also to be compatible with other compilers using NDK3.2, define
__NOLIBBASE__
, and always declare the required library bases yourself.
phx is offline  
Old 22 August 2022, 19:35   #4
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,214
All I'm saying is that there are two pragma headers for exec, one taking a6 from location 4 (AbsExecBase), and one from SysBase. If you include the firs one (which is the default), then declaring SysBase is not required, which would explain that no obvious problem is detected when calling functions in exec (and the call being a bit slow), but if the second one is used (sorry, forgot the file name), then a missing definition of SysBase will be detected by the linker.
Thomas Richter is offline  
Old 24 August 2022, 18:42   #5
Jami
Bruno
 
Jami's Avatar
 
Join Date: Aug 2020
Location: Nantes / France
Posts: 111
@Thomas : Thank for your answer. Actually the problem I had was occuring at compiling stage.


Quote:
Originally Posted by phx View Post
Usually the problem shouldn't occur, because you should set up your vbcc config file for aos68k (and aos68km) in a way that the vbcc-headers always have priority over the NDK-headers (the Installer for AmigaOS does that automatically).
Maybe the "Installing for DOS/Windows" paragraph in manual "vbcc.pdf" could be amended to warn users they should manually include NDK-headers AFTER vbcc-headers (in VC frontend configs or in Makefile or whatever)?

Quote:
Originally Posted by phx View Post
To be on the safe side, and also to be compatible with other compilers using NDK3.2, define
__NOLIBBASE__
, and always declare the required library bases yourself.
Thank you phx for this tip
Jami is offline  
Old 24 August 2022, 23:24   #6
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by Jami View Post
Maybe the "Installing for DOS/Windows" paragraph in manual "vbcc.pdf" could be amended to warn users they should manually include NDK-headers AFTER vbcc-headers
Good hint.
Did that now, before I forget it again. Same for Unix installations.
phx is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Target Renegade Havie project.Amiga Game Factory 183 26 November 2022 08:54
Segmentation fault VBCC on Debian target warpos Hedeon Coders. C/C++ 4 01 May 2021 21:20
Improved input target Lucas request.UAE Wishlist 2 13 September 2013 14:42
Alien Target Shoonay Games images which need to be WHDified 14 30 January 2012 16:58
Monkey Amiga Target 0.25 bruZard News 0 13 December 2011 21:20

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:16.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.10883 seconds with 15 queries