pdcurses installation has a type declaration error

80 views Asked by At

I'm making a text-based game in C using the pdcurses library (version 3.4). I'm following a tutorial for the installation of pdcurses, and the tutorial uses version 3.4. If I download a newer version (e.g. 3.9), it seems to be a completely different installation process which I don't understand at all.

This is the file system of my project, in case I installed it incorrectly unknowingly.

  • bin --- main
  • include --- blocks.h --- grid.h
  • lib --- pdcurses.lib
  • pdcurses --- curses.h --- panel.h
  • blocks.c
  • grid.c
  • main.c
  • makefile
  • pdcurses.dll

When I run make, I get this error:

pdcurses/curses.h:92:23: error: two or more data types in declaration specifiers 92 | typedef unsigned char bool; /* PDCurses Boolean type */ | ^~

My compilation command: gcc -std=c17 -g -Wall -Iinclude -Ipdcurses main.c blocks.c grid.c -o bin\tetris -Llib

I've tried reinstalling pdcurses, and even substituting the typedef unsigned char bool; with #include <stdbool.h>

EDIT: Thanks to William McBrine's responses, I have fixed the issue by simply downloading PDCurses 3.9 and following the build instructions in wincon/README.md and adding the files to my MinGW folder. Thank you!

2

There are 2 answers

3
William McBrine On BEST ANSWER

Your basic problem is that bool is part of standard C since C99, but is also required by the curses spec, which predates C99. PDCurses targets C89 and later. This particular conflict was addressed in PDCurses 3.7, with some further adjustment in 3.9, although it remains a potential problem.

3.9 arranges its file hierarchy slightly differently from 3.4, but the difference isn't that great. I don't know what tutorial you're referencing, but if I did, perhaps I could clarify things. Getting you onto the latest available version is by far the best solution.

Meanwhile, do you really need that "-std=c17"? You could perhaps try "-std=c89".

1
Lake On

It sounds like another header file has bool defined somewhere else.

Depending on what compiler you are using, you may need to wrap the definition in a #ifndef/#endif macro to tell the compiler to skip that type definition since it is already defined by another file.