This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: I think this is a bug...(arguments given to macro 'erase')
- To: rtarpine at hotmail dot com
- Subject: Re: I think this is a bug...(arguments given to macro 'erase')
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sat, 23 Oct 1999 13:58:05 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <3808E7D2.AF792549@hotmail.com>
> Including ncurses seems to screw up vector::erase. Adding -lncurses
> to the commandline makes no difference. I've attached code that
> makes my error ("arguments given to macro 'erase'") in the smallest
> space possible I know how, along with the .ii file gcc makes(in
> tar.gz). And that's another thing: I am a very beginner programmer,
> only 15, so if this is an error on my part (which it most likely is,
> but I can't see it), please forgive me!
Thanks for your bug report. Don't worry about not seeing the problem;
it confused me as well. Please note that the compiler refers to
"macro" erase, whereas the relevant line contains a method call (of a
vector method).
The problem lies in curses.h. My copy reads:
#define erase() werase(stdscr)
So erase is a macro with no parameters, and since the preprocessor is
run before the compiler proper sees the code, you get a problem: You
cannot use <curses.h> and <vector> together (which is quite
unfortunate).
> Is this way of catalogging objects very bad? Ineffecient? Is there
> a better (but hopefully not too complicated) way?
If you have a lot of objects, that can become very in-efficient. They
call it "linear search", which means that the time needed to find the
object has a constant ratio to the total number of objects. Also,
moving the rest of the vector to fill the gap might be in-efficient.
If you use a set<foo*> instead, you get an erase method that takes a
foo* directly. It uses a binary search in a tree, which is much
quicker.
Hope this helps,
Martin