Hello,

I need help concerning <curses.h> and <conio.h> libraries issues. There's a conflit between both libraries when I compile my software in Dev-C++ (XP OS).

1. In <curses.h> there's this code line:
.
.
.
extern int COLORS,COLOR_PAIRS;
.
.
.

2. In <conio.h> there's this code line:
.
.
.
typedef enum
{
BLACK,
BLUE,
.
.
.
YELLOW,
WHITE
} COLORS;
.
.
.

3. When I compile my software there are the following errors messages:

curses.h --> 'int COLORS' redeclared as diferent kind of symbol
conio.h --> previous declaration of 'typedef enum COLORS COLORS'
curses.h --> declaration of 'int COLORS'
conio.h --> conflicts with previous declaration 'typedef enum COLORS COLORS'

Please, how can I solve this conflit? Any good idea?

Thankx in advance.

jmangu

Recommended Answers

All 7 Replies

If you're using conio.h, you have no need for curses, and vice-versa.

Decide which library you like (conio.h) <cough, cough>, and forget the other. ;)

Thankx Adak.

It didn't solve completly my problem. Now, there's a problem in a 3rd library (<dos.h>) when I compile my software (I've try to remove the <curses.h> and the <conio.h> one at a time).

Here's the code:

// example program for the PSC232

#include <dos.h>
#include <stdio.h>
#include <conio.h>
//#include <curses.h>
#include <string.h>
#include <stdlib.h>
#define  DTARDY  0x01 
#define FALSE      0//0r
#define CR         0x0d
#define LF         0x0a
#define TRUE       !FALSE
#define RS232      0x14
#define COM1       0x3f8
#define LSR        5
#define THR        0
#define THRRDY     0X20

int stop=0,c;


int xmit(int)
{
   char ch;

   register int cnt;
   cnt = 0;
   while(!(inportb(COM1+LSR) & THRRDY) && cnt < 10000) cnt++;
   if (cnt>=10000)
     return(-1);
   outportb(COM1+THR,ch);
   return(0);
}




// ********************** init *********************************
void setup()
{
    union REGS regs;
    regs.h.ah = 0;              // ah = init
    regs.x.dx = 0;              // dx = comport#1=0 #2=1 #3=2 #4=3
    regs.h.al = 0xe7;           // 9600bd, 8bit, no par, 1 stop (c3=4800)
    int86(RS232, &regs, &regs); // call bios int14
}

// ******************** transmit ************************************
void send(char *source)        // scan ascii line
{
   char dest[]=" ";
   int len,i;
   len=strlen(source);
   for (i=0; i<len; i++)
   {  strncpy(dest, source, 1);
     xmit(*dest);              //
     source++;}
}


// ********************* character to screen ********************************
int put_ch(int)
{
    int c;
    union REGS regs;
    regs.h.ah = 2;              // 2 = char out
    regs.h.dl = c;
    intdos(&regs,&regs);
    return(TRUE);
}

int putscrn(int)
{   
   char c; 
    char d=c;
    if(c>=' '|| c==CR || c==LF ) put_ch(c);
    return(d);
}
// ********************** receive *************************************
int chrdy()
{
    return(inportb(COM1+LSR) & DTARDY);
}
int rch()
{
    return(inportb(COM1) & 0x7f);

}
void receive()
{char d;
 do{
    if(chrdy()){d=rch();
    putscrn (d);}
   }
while (d!=4);    // the last character = EOT
}

// ************************* main *******************************************
int main()
{ int c;
  char d;
  system("cls");
  //clrscr();
  printf(" Example program for PSC232 \n");
  setup();

 printf("*IDN?\n\r");
   send("*IDN?\n");
  printf("RECEIVE...\n\r");
loop:
   receive();

goto loop;
}

Those are the errors messages when I compile the software (XP OS and Dev-C++):

[Linker error]undefined reference to 'inportb'
[Linker error]undefined reference to 'outportb'
[Linker error]undefined reference to 'int86'
[Linker error]undefined reference to 'intdos'
[Linker error]undefined reference to 'inportb'
[Linker error]undefined reference to 'inportb'
Id returned 1 exit status

Is there a solution for this? Many thankx in advance.

jmangu

32-bit compilers such as Dev-C++ do not support any of the functions in dos.h. Those functions won't work on MS-Windows operating system since Win98 (10-20 years ago).

dos.h functions work fine in WindowsXP and Windows2000 (both 32 bit), but the compiler has to support those functions. It appears that Dev-C++ does not do that.

Turbo C supports all the dos.h functions that I've tried, over the years. (I have Turbo C/C++, ver. 1.01). It's a free download at the legacy Borland download site - you may want to use it, instead of Dev-C++, to get those functions working. It has conio.h included, so you don't need to worry about using curses at all.

Tubbo C is not a 32-bit compiler. It was written 20 years ago for MS-DOS, not Windows.

Yes, but the dos.h functions WORK in WindowsXP, as does conio.h.

>>but the dos.h functions WORK in WindowsXP
Actually not. They work in a DOS emulation window, which emulates MS-DOS 6.X, not MS-Windows. You can not make dos.h work with any 32-bit compiler because they use priviledged instructions which the 32-or 64-bit operating systems will not allow.

conio.h is spported by many 32-bit compilers because there are no functions in it that directly attempt to call privileged instructions. I stepped into kbhit() function and it eventually calls win32 api console functions. I suspect the other functions do the same thing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.