Error with too many #defines

Questions, bug reports, features requests, ... about the Oric Software Development Kit. Please indicate clearly in the title the related element (OSDK for generic questions, PictConv, FilePack, XA, Euphoric, etc...) to make it easy to locate messages.

Post Reply
User avatar
Chema
Game master
Posts: 2029
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Error with too many #defines

Post by Chema » Thu Feb 23, 2017 7:54 pm

Hi all. I solved it temporary, but I faced today an error with the OSDK related with a too high number of #defines. I know this, because I simply commented some I did not need, and it worked.

I am not sure if it is cpp which is producing the error, but I guess so. The error message is:
fa77:no more memory error
Dbug, I guess it is related with the size of an internal table, but anyway it should be changed to something practically unlimited :)

EDIT: I traced the error in the sources of xa. It is flagged as E_OUT_OF_MEMORY whenever a number of entries (I think) is greater than a constant ANZDEF, defined in xah.h as

Code: Select all

#define   ANZDEF    2340      /* mal 14 -> Byte , ANZDEF*14<32768       */ 
BTW, I love clear comments :evil:

User avatar
iss
Flight Lieutenant
Posts: 487
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Error with too many #defines

Post by iss » Thu Feb 23, 2017 9:13 pm

Chema wrote:BTW, I love clear comments :evil:
The comments are clear in German :wink: :
"ANZDEF" = Anzahl der Defines = Number of defines
"mal 14" = multiplication by 14

Else, as workaround I can recommend you to use C pre-processor before XA.
I added permanently "cpp" to my OSDK toolchain and it's called by make.
I use an old version like this one here: https://dev.w3.org/Amaya/cpp/
If you need I can zip and my version of these sources or I can try to compile them for Windows.

User avatar
Chema
Game master
Posts: 2029
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Error with too many #defines

Post by Chema » Thu Feb 23, 2017 11:17 pm

Thanks iss, now I understand :D . My comments are usually even more obscure.

I solved the error for now, but I think it's better to patch this, so it does not become an issue. It is probably a limit of using 16bit signed integers, but visual studio has been using 32 bit integers for quite some time... If I am not mistaken.

User avatar
Dbug
Site Admin
Posts: 2357
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Error with too many #defines

Post by Dbug » Fri Feb 24, 2017 9:01 am

iss wrote:Else, as workaround I can recommend you to use C pre-processor before XA.
I added permanently "cpp" to my OSDK toolchain and it's called by make.
I use an old version like this one here: https://dev.w3.org/Amaya/cpp/
If you need I can zip and my version of these sources or I can try to compile them for Windows.
There is a CPP already in the bin folder of the OSDK (It's used before the C compiler is called, and also to apply the macros.)
Did you miss it, or is it that it did not work for what you needed?

User avatar
iss
Flight Lieutenant
Posts: 487
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Error with too many #defines

Post by iss » Fri Feb 24, 2017 1:01 pm

Dbug wrote:Did you miss it, or is it that it did not work for what you needed?
Yes, you are right, there is "cpp.exe" in OSDK! :oops:

Code: Select all

cpp.exe -v
GNU CPP version 2.8.1 (80386, BSD syntax)
But now I recall the case...
Because I'm using Linux and cpp's sources are missing in the svn,
I found them (the same version 2.8.1) from somewhere on the net and added them, so I can fully recompile OSDK for Linux.

User avatar
Dbug
Site Admin
Posts: 2357
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Error with too many #defines

Post by Dbug » Fri Feb 24, 2017 4:55 pm

I guess we could totally have the cpp sources in the osdk source tree on SVN, assuming there's no licencing issues and that it's not a monster that drags 20 billions dependencies?

User avatar
Chema
Game master
Posts: 2029
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Error with too many #defines

Post by Chema » Fri Feb 24, 2017 4:58 pm

In any case, XA is not using cpp but it's own preprocessing, and I am not sure they are fully compatible or if there will be any kind of lateral effect.

As I use assembly only, I'd be very grateful if this one is fixed :) please? <insert begging here>

User avatar
Dbug
Site Admin
Posts: 2357
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Error with too many #defines

Post by Dbug » Fri Feb 24, 2017 9:44 pm

Could you try this version:
xa.zip
XA v2.2.4
Extended the size of MAXBLK from 16 to 32, MAXFILE from 7 to 15, MAXLINE from 8192 to 16000 and ANZDEF from 2340 to 10000
(77.27 KiB) Downloaded 21 times
While I was at it, I changed some other values:

Code: Select all

#define   MAXBLK    32                  // Was 16
#define   MAXFILE   15                  // Was 7
#define   MAXLINE   16000               // Was 8192		// 2048 -> Explodes with large recursions
#define   ANZDEF    10000               // Was 2340      /* mal 14 -> Byte , ANZDEF*14<32768       */

User avatar
iss
Flight Lieutenant
Posts: 487
Joined: Sat Apr 03, 2010 5:43 pm
Location: Bulgaria
Contact:

Re: Error with too many #defines

Post by iss » Fri Feb 24, 2017 10:56 pm

This new defines are OK by me.
One curious detail: Can you guess what is the maximum usable value for ANZDEF?
It's exactly 89557 :shock:
I used generated file with 100,000 defines and after some trial-and-error found this limit.
If "#define ANZDEF 89558" the program exits with "Segmentation fault".

Else, for cpp sources - I think it's not worth to bother with them.
What still puzzles me is - from where I've got these sources?!? maybe it was from LCC65...

User avatar
Chema
Game master
Posts: 2029
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Error with too many #defines

Post by Chema » Sun Feb 26, 2017 8:49 pm

Yeah! This version seems to work perfectly!

I was starting to need it badly. A single more #define and I got the error. I found a limit in the number of labels (I think) when developing 1337 and now this... but Dbug came to rescue :)

User avatar
Dbug
Site Admin
Posts: 2357
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Error with too many #defines

Post by Dbug » Mon Feb 27, 2017 7:00 pm

Just for the sake of not forgetting, and also to test the new server, I added an issue on that one:
http://osdk.org/index.php?page=issues

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest