clinuxturbo-ckbhit

make gives me a error I don't understand with TurboC


I am trying to learn C, for fun. I am using a Linux distro. I am trying to compile a program which uses kbhit(). I found a way to this with TurboC (http://www.sandroid.org/TurboC/#Download).

I followed the instructions but make gives me this:

gettext.c: Dans la fonction « gettextTurboC »:
gettext.c:93:13: warning: les cibles pointées dans l'affectation de « int8_t * » {alias « signed char * »} vers « uint8_t * » {alias « unsigned char * »} diffèrent dans la plage signée [-Wpointer-sign]
   TurboData = (int8_t *) dest;
             ^
In file included from TurboC.h:60,
                 from conio.h:49,
                 from gettext.c:42:
TurboC.h:250:14: error: expected « ) » before « int32_t »
 #define long int32_t
              ^~~~~~~
/usr/include/curses.h:1238:66: note: dans l'expansion de la macro « long »
 #define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT)))
                                                                  ^~~~
gettext.c:124:10: note: pour correspondre à ce « ( »
  Color = PAIR_NUMBER (ch & A_COLOR);
          ^~~~~~~~~~~
gettext.c:125:23: warning: les cibles pointées dans le passage de l'argument 2 de « pair_content » diffèrent dans la plage signée [-Wpointer-sign]
  pair_content (Color, &dFore, &dBack);
                       ^~~~~~
In file included from TurboC.h:60,
                 from conio.h:49,
                 from gettext.c:42:
/usr/include/curses.h:746:28: note: « short int * » attendu mais l'argument est de type « uint16_t * » {alias « short unsigned int * »}
 extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*);  /* implemented */
                            ^~~~~~~~~~~~
gettext.c:125:31: warning: les cibles pointées dans le passage de l'argument 3 de « pair_content » diffèrent dans la plage signée [-Wpointer-sign]
  pair_content (Color, &dFore, &dBack);
                               ^~~~~~
In file included from TurboC.h:60,
                 from conio.h:49,
                 from gettext.c:42:
/usr/include/curses.h:746:28: note: « short int * » attendu mais l'argument est de type « uint16_t * » {alias « short unsigned int * »}
 extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*);  /* implemented */
                            ^~~~~~~~~~~~
make: *** [Makefile:126: gettext.o] Error 1

I really don't know what to do with this error:

TurboC.h:250:14: error: expected « ) » before « int32_t »
#define long int32_t

Can somebody help me?


Solution

  • I am trying to learn C, for fun. I am using a Linux distro.

    A Linux distribution is an excellent choice to learn C. Notice that it is made of free software, whose source code you could study. You'll learn a lot by studying the source code of small free software programs written in C (e.g. those from coreutils, or a simple shell like sash, etc.).

    If you want to learn C programming, start first with simple command line programs using standard streams (a program which handles directly the keyboard is something complex, not for newbies) and restrict yourself to use only the C standard library at first.

    (the code in your question is not in standard C -since it uses some external library-; I don't recommend trying that at first)

    Later, when you are more familiar with the C programming language, you could use some external libraries. A Linux distribution has lots of them. You may need to install development packages for them, e.g. libncurses-dev on Debian or Ubuntu for ncurses.

    A very important notion in C is undefined behavior. Learn more about it, avoid it, be scared of it.

    I am trying to compile a program which uses kbhit()

    Notice that kbhit and <conio.h> are not in the C11 standard (see n1570...), and they are not in the C standard library, so don't use them (and you won't find any direct equivalent on Linux or POSIX).

    On Linux, you might want to use ncurses. Of course, you need to spend a few days learning it and studying its documentation. You won't find a direct equivalent to kbhit. Read the NCURSES programming howto.

    You may want to use some non-standard libraries (Linux has lots of them). Then read Program Library HowTo.

    The terminal (and terminal emulators, and the line discipline) is a complex thing. Read The TTY demystified, termios(3), pty(7). You really want to use some library such as ncurses (or perhaps readline).

    geany is not a compiler, but a source code editor. See this answer to a related question.

    You probably want to use some build automation tool, such as GNU make. It will run the gcc compiler for you. So read How to invoke GCC.

    Once you are familiar with C programming in general, you might want to learn more about Linux programming, so read ALP.

    PS. TurboC is an ancient C compiler (not standard conforming) that you should even forget. It does not exist on Linux. GCC is a good, standard conforming, C compiler. You should use it with all warnings and debug info, i.e. compile yoursourcecode.c as gcc -Wall -Wextra -g yoursourcecode.c -o yourbinary on Linux. Read also How to debug small programs. The valgrind tool is also very useful (and available on Linux) to debug memory leaks.

    When asking questions on StackOverflow, be sure to set your locale to English. We are not supposed to decipher compiler diagnostics in French.