2

I am making a very simple platform independent(at least that's the plan) console app. I changed from conio.h to pdCurses to make it happen. The problem with that is that in Windows, using Codeblocks and gcc I have a problem.

When I include I get tons of errors. They all concern 3 macros all located in different source files inside:

CodeBlocks\MinGW\bin..\lib\gcc\mingw32\3.4.5........\include\c++\3.4.5\bits\

If I undef those 3 macros like this:

#include <curses.h>


#undef move
#undef erase
#undef clear

then all compiles well. If I don't undef then I get tons of errors about these macros.

Example errors are:

macro "move" passed 3 arguments, but takes just 2|
\bits\char_traits.h|185|error: invalid function declaration|
\bits\basic_string.h|604|error: expected `)' before '->' token|
\bits\basic_string.h|1039|macro "erase" passed 2 arguments, but takes just 0|

Anyone has any idea why this happens? And any not so damn ugly way to correct the problem? Thanks in advance for your input.

Edit: I am also getting undefined references to various things whenever I invoke any pdcurses functions. I can not understand why. I definitely linked the library correctly. For example by trying to echo a char on the screen I get:

main.cpp|74|undefined reference to `__imp__SP'|
main.cpp|74|undefined reference to `__imp__stdscr'|
main.cpp|74|undefined reference to `__imp__stdscr'|

Can it be anything other than bad linking of the library? And how can I see what's wrong with the linking of pdcurses fromthe above errors?

-Lefteris

2 Answers 2

1

For the macro problem, do a search for "STL" in the curses.h file and you should find:

#ifdef __cplusplus
#ifndef NCURSES_NOMACROS
/* these names conflict with STL */
#undef box
#undef clear
#undef erase
#undef move
#undef refresh

#endif /* NCURSES_NOMACROS */

Maybe you can find a work around with that.

EDIT: In my copy if you #define NCURSES_NOMACROS it will skip defining all the macros. As far as I looked all of them are just convenience macros for the standard screen so you really don't lose any functionality but you have to use the functions that explicitly require the screen variable. Or, I suppose, use your own macros that don't have name clashes.

0

A. I don't know why the problem is there (it doesn't happen in MSVC with PDCurses), but the "proper way" is to implement your own header that has the correct directives and include that instead.

B. Looks like a linking error to me, but why don't you show the corresponding code?

1
  • Thanks for A, I will try to do it that way. For B, yes it looks like a linking error to me too, but I did link the library correctly from codeblocks just as I do with any other library. As for the corresponding code, it could be anything. Any pdcurses function will throw this or some similar undefined reference.
    – Lefteris
    Jul 16, 2009 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.