I have newly made my bcstring class, and it is having some strange errors.
I have given it the ability of dynamically allocating memory. If the memory to be allocated is already allocated, nothing happens (correct/non-problematic); If the memory to be allocated is greater than that that is allocated, and correct parameters are set to allow the automatic allocation, memory is allocated (correct/non-problematic); If the memory to be allocated is less than that that is already allocated, memory is checked against the threshold to see if a new amount of space should be allocated. Then if the difference of the two amounts does exceed the threshold, memory is allocated (error/problematic).
So far these seem to be the only major errors, but this error is in the function that is used most commonly throughout the class, so any function that makes a call to "bcautoallocate" with those specified parameters has errors.
This error causes a sudden termination of the application using this class.
bcstringClass can be downloaded from:

http://brentsite.bravehost.com/
--Use the 'box'
--Please don't comment on the site, it hasn't been updated in about 9 months with the exception of this upload. I am particularly unskilled in web programming and my only internet access is through the public library.

tester.cpp is the executable source code.
bcstring.h is the bcstring class
errors.h contains no actual code, but rather details of some errors.
bcqueue.h contains a class for a futere addition to the bcstring class (ignore this)
bcparams.h constains a class for a future addition to the bcstring class (ignore this)
Those 2 files were included only because they are a part of the dev-cpp project file.
It should be attached to this thread, but just in case...

I am asking for help on how to fix the error, I have told you essentially all I know about the error.
I have spent about 2 weeks trying to solve this error, where the rest of the code took about 3 days to write and 1 day to debug. I was hoping not to have to use daniweb this time, but it seems I have failed.

Recommended Answers

All 11 Replies

I have Dev-C++ version 4.9.9.2 and using the project file in your zip file the compiler produced a flood of errors and warnings. You need to go through bcstring.h and fix them all one at a time.

>>I have spent about 2 weeks trying to solve this error
You are a lot more patient than most programmers :) Save yourself a lot of headaches and NEVER EVER assume warnings are ok -- in most cases they are really errors. Only after getting a completly clean compile can you even begin to debug the program.

Note: the file you attached to your thread is not readable by WinZip but the file at the web site is ok. Are they supposed to be the same ?

Note: the file you attached to your thread is not readable by WinZip but the file at the web site is ok. Are they supposed to be the same ?

Yes, they are supposed to be the exact same. Same file was uploaded for each.
What happened is before I uploaded the code I went through and took out a couple lines of code that were useless, and would only cause confusion for the people helping me.
1 bracket was missing so everything went wrong... I have re-uploaded to my 'box', so re-download it if you will...
I would just tell you where to put the }, but I needed to fix a couple other things as well.

I don't normally ignore warnings, because I have learned from the past that they can cause major errors in the future.

The main reason that I have spent so much time on this is because I have rewrote it 3 times (this being 3), and I refuse to have wasted that much time on nothing.
1) USed new/delete method, absolute failure
2) Used malloc method, eventually got out of hand and needed to be trashed
3) Uses new/delete[] method (notice the [], after writing this I went back to my oldest code and found that that was my single error) for the most part, successful

I changed my uploaded file, hopefully it works now. (It worked for me to begin with, so...)
Maybe you just have to giv it time to do something? The first one woks for me, but didn't when you tried it first.
The second one gives me a corrupt message.

Just tried it again, and WinZip reports this error

End-of-central-directory signature not found. Either this file is not a Zip file, or it constitutes one disk of a multi-part Zip file

[edit]Ok -- tried it again and this time it worked ok [/edit]

You are using the newly uploaded one right?

Dev-C++ compiles that without any errors. But VC++ 2005 shows several errors that Dev-C++ did not catch.

d:\dvlp\tester\tester\bcstring.h(144) : warning C4138: '*/' found outside of comment
d:\dvlp\tester\tester\bcstring.h(635) : warning C4800: '__int64' : forcing value to bool 'true' or 'false' (performance warning)
d:\dvlp\tester\tester\bcstring.h(882) : warning C4244: 'initializing' : conversion from '__int64' to 'size_t', possible loss of data
d:\dvlp\tester\tester\tester.cpp(18) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\dvlp\tester\tester\tester.cpp(42) : error C2039: 'ToFile' : is not a member of 'bcstring'
d:\dvlp\tester\tester\bcstring.h(94) : see declaration of 'bcstring'
d:\dvlp\tester\tester\tester.cpp(45) : error C2039: 'ToFile' : is not a member of 'bcstring'
d:\dvlp\tester\tester\bcstring.h(94) : see declaration of 'bcstring'
Generating Code...
Build log was saved at "file://d:\dvlp\tester\tester\Debug\BuildLog.htm"
tester - 4 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The error on line 635 can be corrected by redefining keepGoing to be long long instead of bool

I don't know how you can correct the error on line 882 -- the new operator takes a size_t object and you are attempting to pass a long long. You can typecast it to size_t but might loose precision if the value is more than what a size_t can hold.

I think you can figure out the rest of the errors.

My suggestion is to scrap Dev-C++ and download free VC++ 2005 Express because it catches more errors and has a really good debugger that can't be beat.

My suggestion is to scrap Dev-C++ and download free VC++ 2005 Express because it catches more errors and has a really good debugger that can't be beat.

I have done this (well, tried to). For some reason, the express version of vc++ simply will not compile, debug, or anything. I may however try to 'conver' to code::blocks, it still uses the ?minggcc? compiler, but provides regular updates whereas dev-c++ hasn't updated in forever.

The problem with keepGoing is that bcputchar has been updated to return the position where it used to return success. This will be fixed.

I will change the long long values throughout to size_t or the equivelant. As you may notice I am trying to keep this without any required importations. So if size_t is the same as just long, I'll use long.
Is size_t 'standard' (as in not requiring a header... what is the correct term)
If it is defined somewhere do you know where?

Thanks for your help thus far, and I will try again to download vc++ express... I must download the iso because the other option requires me to be at my computer and as I stated before, my home computer has no internet.

I have done this (well, tried to). For some reason, the express version of vc++ simply will not compile, debug, or anything.

You installed it incorrectly. What version of Windows are you using anyway ?

I will change the long long values throughout to size_t or the equivelant. As you may notice I am trying to keep this without any required importations. So if size_t is the same as just long, I'll use long.

size_t is normally (but not always) defined as unsigned int

If it is defined somewhere do you know where?

depends on the compiler.

My os is XP, I don't know what updates, and can't look right now.
I will try to install it again.

Also, does the express edition allow files to be compiled into working executables, or just run as processes?

My os is XP, I don't know what updates, and can't look right now.
I will try to install it again.

Also, does the express edition allow files to be compiled into working executables, or just run as processes?

Yes it will create the executable. It has the same compiler as all other versions of VC++, the difference is the additional bells-and-whistles.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.