Cannot Load Source File Error

Just starting out? Need help? Post your questions and find answers here.
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Cannot Load Source File Error

Post by Jumbuck »

Hi,
Can anybody help.
My rather large program was working O.K until I added another Include
file. Would not load with the following error;-
"Cannot Load Source File" with a compiler error;-
"Invalid Memory Access(Write Error At Address 31794372)"
This program has 126 Include files and I find that if I delete ANY one of
the Includes it will then load and run O.K and happily accept the Include
file I am trying to add. A reboot makes no difference.
Running PB 4.30 with Widows XP Home SP2, AMD 64 Athlonx2, 2gig Ram,
and heaps of hard disk space.
This program will need many more Include files to complete.
Jumbuck.
eJan
Enthusiast
Enthusiast
Posts: 366
Joined: Sun May 21, 2006 11:22 pm
Location: Sankt Veit am Flaum

Post by eJan »

Try to using 'Start' & 'End' Labels in DataSection (a good example): http://www.purearea.net/pb/CodeArchiv/F ... udeFile.pb
Image
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Cannot Load Source Error

Post by Jumbuck »

I now beleive that this error must have occurred for other users when
their programs reached a certain size.
It would appear that it is a problem within the IDE & Debugger limiting
the use for larger programs which is a shame because as a novice I am
just beginning to grasp some of PB's capabilities.
At the suggestion of another member I tried turning off the compiler
debugger and hey presto no problem any more.
But isn't a debugger supposed to be of help to the programmer irrespective of the size of his/her program?.
I saw a post recently which said something like " If the written code were
of sufficient quality then debugging should not be needed".
Well this may well be O.K for experienced programmers but does nothing
to help novices.
The program I was converting to PB has fallen down at 14000 lines but I
still have nearly 30000 lines to convert. This is going to be a mammoth
task if unable to debug.
If the author of PB or any member out there can offer me a solution to
this then I would be very grateful. I need to debug my code.
Jumbuck.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Cannot Load Source File Error

Post by PB »

126 include files? WTF? That's just insane. How big (in KB) is each such file?

Anyway, to try to resolve your problem: open some of those include files and
try deleting any blank lines in them. There may be a line limit that the editor
has reached, so deleting blanks may help.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Perhaps you are including the same file multiple times. If so substituting XIncludeFile for IncludeFile would help.
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Probably have to do with how the PB Debugger keeps track of which line and include that is currently executed. I think they use a long to keep track of current line and current include, 8-bit for indexing the includes and 24 bit for the linecount. Assuming i'm right about this i think that if the PB team would use a unsigned byte to index the includes instead of a signed byte you would in an instant be able to have 255 include files in a project.

However it seems to me that having in excess of 126 include files in a project is rather pointless and cutting down the amount should be an easy task.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

However it seems to me that having in excess of 126 include files in a project is rather pointless and cutting down the amount should be an easy task.
Pointless?

To whom?

That is your opinion, nothing more.

Some people may like to overload their IDE environment with thousands of lines of code and constantly fold and unfold their lines to read what they are working on.

Still others like to neatly just include the modules in ways that make sense to them.

Many use a combination of the two. Horses for courses.

The IDE should not arbitrarily limit someone to one or the other

I've used MANY languages over 28 years that included all the above methods. Some had literally THOUSANDS of include directives and they worked fine.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Fangbeast wrote:
However it seems to me that having in excess of 126 include files in a project is rather pointless and cutting down the amount should be an easy task.
Pointless?

To whom?

That is your opinion, nothing more.
Well, as i said that it seemed pointless to ME. One could assume that I am the one thinking it's pointless, and yes that's my opinion, people can share it or disagree with it.

However arguing about what's right and what's not is also rather pointless, as things at the moment are as they are. He have hit a hard limit in the current incarnation of the PB language and one way around it is to limit the amount of includes. The question is, do he continue with his project or wait for an unknown time until this limit is removed?
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

Forgetting what's right or wrong and focusing only on what's possible :wink:, here are some statistics I measured on the limitations of Includes.

I can have only 126 levels of Includes (one calling another). The compiler will will say it's >128, even though it maxes out at 126.
I can have only 133 single level includes with the debugger running.
I can have 300+ single includes without the debugger running.
I can have 300+ include files that each include 126 levels.


From this I would conclude that if includes are causing a problem, flatten them. The limitations with the debugger would have to adjusted so that it matches what is also compilable (why compile code you can't debug?). Perhaps the level of Includes could be increased, the limitation seems to be arbitrary.

Flattening the includes could be done with a tool (based on the enormous count). The tool may have to be written. As noted above, the flattening would have to be flattened so that it wasn't deeper than 126 levels.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

He have hit a hard limit in the current incarnation of the PB language and one way around it is to limit the amount of includes.
I don't believe there is a hard limit as I have seen countless projects far exceed this. A problem with the debugger perhaps, not the IDE in general.

I hit countless problems with the debugger early on, reported it and left it at that.
The question is, do he continue with his project or wait for an unknown time until this limit is removed?
Continue of course. This little thing has not slowed the professional coders in the forum (of which sadly, I am not).

Whilst having a debugger would arguable be better, that would merely be my opinion however, I route all debug messages to the error log and can happily code like a pig in poo.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Post by yrreti »

Jumbuck, I have a question?
Why would you want to use so many includes in the first place?
I know it's kind of nice to modularize your code a bit so you can easily
re use your code. But there come a point where your main program
could start to get more and more confusing to work on, change, and debug,
because of all the external code. There could possibly be some limitation
when using the debugger with so many includes. But I have to admit
that it amazes me just how well that debugger does in keeping track of
where it is with all those includes as it is.
As a suggestion, wouldn't it be better to try to combine some of those
includes together, or to just write some of them into your main code?
As a comparison example. If I have 10000 different files on drive D:\.
It would be hard to find the file I needed. But if I created different directories.
Say \a to \z, and organized the files by the first letter into their prospective
directories. Or if I arranged them according to what they were used for, it would
make it a lot easier to locate and work on.
Simularly wouldn't it make it less confusing to work on, change, and debug.
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Post by yrreti »

Fangbeast
Whilst having a debugger would arguable be better, that would merely be my opinion however, I route all debug messages to the error log and can happily code like a pig in poo.
This sounds like an interesting idea you use here which I would like to be able to use myself on occasion.
I would really appreciate it if you could possibly share some of the code you use to do that and how you can set it up.
I would probably create a file and write debug stuff to it, but your experience is much greater then mine and you probably
have a much better approach then mine. (especially error messages)
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

yrreti wrote:Fangbeast
Whilst having a debugger would arguable be better, that would merely be my opinion however, I route all debug messages to the error log and can happily code like a pig in poo.
This sounds like an interesting idea you use here which I would like to be able to use myself on occasion.
I would really appreciate it if you could possibly share some of the code you use to do that and how you can set it up.
I would probably create a file and write debug stuff to it, but your experience is much greater then mine and you probably
have a much better approach then mine. (especially error messages)
No code yrreti, I am not smart enough to do that, LOL!! It's just a program preferences option. When I had problems with the debugger not working, this is what I did and now all my debug messages are shown there. I keep the error log open by default for all programs and resize it when I want to read it.

File/Preferences/Debugger/Individual Settings/Display debug output in the error log
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

I use a mix of diferent approaches. I use Debug, the Debugger (though not too much, or not even enoough, I guess), and I use a bunch of routines called x_log() etc. that open up one more additional logfile and window. As I have two 22" monitors on my desk, desktop real estate isn't much of a problem to me.

If it's a bug or limitation, then yeah, go ahead and ask the PBdevs to fix it (if possible).

However, I am mightily interested what kind of problem you need so many includes for! Could you give us an idea?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Jumbuck
User
User
Posts: 63
Joined: Mon Nov 03, 2008 8:30 am
Location: Australia

Error Source Load

Post by Jumbuck »

Thanking all for replies.
I intend to add "DISABLE DEBUGGER" as the first line of my program
and move on.
Maybe this limitation will be fixed one day.
Jumbuck.
Post Reply