This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: I think this is a bug...(arguments given to macro 'erase')


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]