From: "Erik Chang" Newsgroups: comp.os.msdos.djgpp Subject: help with compiling Date: Mon, 29 Oct 2001 15:50:30 -0600 Organization: Rice University, Houston TX Lines: 432 Message-ID: <9rkimd$2gl$1@joe.rice.edu> NNTP-Posting-Host: ro-lab9.rice.edu X-Trace: joe.rice.edu 1004391949 2581 128.42.98.204 (29 Oct 2001 21:45:49 GMT) X-Complaints-To: abuse AT rice DOT edu NNTP-Posting-Date: 29 Oct 2001 21:45:49 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi All, I am trying to complie two different codes together, one with extension *.c and the other with *.cpp. The tcint70.c contains the function called by ctbase.cpp, and the way I do the compiling and linking is bcc ctbase tcint70.c However, the following error message come out Borland C++ Version 3.1 Copyright (c) 1992 Borland International ctbase2.cpp: tcint70.c: Turbo Link Version 5.1 Copyright (c) 1992 Borland International Error: Undefined symbol quit70h() in module ctbase2.cpp Error: Undefined symbol init70h() in module ctbase2.cpp It seems that the linker cannot find the two functions defined in tcint70.c. Why is that? Can this be solved by specifying some parameters? Furthermore, if I integrate the codes in tcint70.c into the ctbase3.cpp codes and then compile it (bcc ctbase3), the following message come out: Borland C++ Version 3.1 Copyright (c) 1992 Borland International ctbase3.cpp: Error ctbase3.cpp 80: Cannot convert 'void (interrupt far*)(...)' to 'void (interrupt far*)()' in function init70h() Error ctbase3.cpp 81: Cannot convert 'void (interrupt far*)()' to 'void (interrupt far*)(...)' in function init70h() Error ctbase3.cpp 81: Type mismatch in parameter '__isr' in call to 'setvect(int,void (interrupt far*)(...))' in function init70h() Error ctbase3.cpp 105: Cannot convert 'void (interrupt far*)()' to 'void (interrupt far*)(...)' in function quit70h() Error ctbase3.cpp 105: Type mismatch in parameter '__isr' in call to 'setvect(int,void (interrupt far*)(...))' in function quit70h() *** 5 errors in Compile *** It seems that the syntax in the c code is not taken by the c++ compiler. I am using the Borlandc 3.1 under the MSDOS mode of Windows 98. The codes are attachted below. Thanks for your help!! Erik -- ____________________________________ Erik Chang Psychology Department-MS 25 Rice University PO Box 1892 Houston, Texas 77251-1892 USA TEL: 713-3482216 FAX: 713-3485221 codes in the order of: ctbase2.cpp ctbase3.cpp tcint70.c tcint70.h ************************************************************************* ctbase2.cpp #include #include #include #include #include #include "tcint70.h" unsigned long int tick_1, tick_2, elapsedtime; void main(int argc, char **argv) { int rt,posi; int rsptype; if (argc == 2) { //ensure correct parameters rsptype = atoi(argv[1]); if (rsptype==1) { init70h(); printf("Timebase set to 1msec.\n"); } else if (rsptype==2) { quit70h(); printf("Timebase set to 55msec.\n"); } else { printf("Usage: ctbase \n"); printf("arg1: 1-1msec; 2-55msec\n"); exit(0); } } else { printf("Usage: ctbase \n"); printf("arg1: 1-1msec; 2-55msec\n"); exit(0); } } ************************************************************************* ctbase3.cpp #include #include #include #include #include #include #include #include #include #include "tcint70.h" #define IRQ8 0x70 #define SET_EVENT 0x8300 #define CANCEL_EVENT 0x8301 #define LARGEST 0xffff #define PIT0 0x40 #define PIT2 0x42 #define PITMODE 0x43 #define PITCONST 1193180L #define KBCTRL 0x61 #define NEW70H 1 static float tick_per_ms = 1.024; static float ms_per_tick = 0.9765625; static char far *event; static unsigned char flag70h = 0; static void interrupt(*old70h) (__CPPARGS); volatile unsigned long int ticks_70h; unsigned long int tick_1, tick_2, elapsedtime; void main(int argc, char **argv) { int rsptype; if (argc == 2) { //ensure correct parameters rsptype = atoi(argv[1]); if (rsptype==1) { init70h(); printf("Timebase set to 1msec.\n"); } else if (rsptype==2) { quit70h(); printf("Timebase set to 55msec.\n"); } else { printf("Usage: ctbase \n"); printf("arg1: 1-1msec; 2-55msec\n"); exit(0); } } else { printf("Usage: ctbase \n"); printf("arg1: 1-1msec; 2-55msec\n"); exit(0); } } void init70h(void) { union REGS regs; struct SREGS sregs; unsigned int event_seg, event_off; if (flag70h != NEW70H) { old70h = getvect(IRQ8); setvect(IRQ8, new70h); event_seg = FP_SEG(event); event_off = FP_OFF(event); regs.x.ax = SET_EVENT; sregs.es = event_seg; regs.x.bx = event_off; regs.x.cx = LARGEST; regs.x.dx = LARGEST; int86x(0x15, ®s, ®s, &sregs); flag70h = NEW70H; } } void quit70h(void) { union REGS regs; if (flag70h == NEW70H) { regs.x.ax = CANCEL_EVENT; int86(0x15, ®s, ®s); setvect(IRQ8, old70h); flag70h = 0; } } void interrupt new70h(__CPPARGS) { disable(); ticks_70h++; enable(); old70h(); } unsigned long time70h(unsigned long start, unsigned long stop) { unsigned long duration, millisec; if (stop < start) return 0; else { duration = stop - start; millisec = duration * ms_per_tick; return millisec; } } void delay70h(unsigned int delayms) { unsigned long int delaybegin = 0; unsigned long int delayend = 0; unsigned int delaytick; if (flag70h == NEW70H) { delaytick = delayms * tick_per_ms; delaybegin = ticks_70h; do { delayend = ticks_70h; } while ((delayend - delaybegin) < delaytick); } else { delaytick = delayms * 0.0182065; biostime(0, (long) &delaybegin); do { biostime(0, (long) &delayend); } while ((delayend - delaybegin) < delaytick); } } void sound70h(int freq, int duration) { int byte; unsigned int freq1; freq1 = PITCONST / freq; outportb(PITMODE, 0xb6); byte = (freq1 & 0xff); outportb(PIT2, byte); byte = (freq1 >> 8); outportb(PIT2, byte); byte = inportb(KBCTRL); outportb(KBCTRL, (byte | 3)); delay70h(duration); outportb(KBCTRL, (byte & 0xfc)); } ************************************************************************* tcint70.c #include #include #include #include "tcint70.h" #define IRQ8 0x70 #define SET_EVENT 0x8300 #define CANCEL_EVENT 0x8301 #define LARGEST 0xffff #define PIT0 0x40 #define PIT2 0x42 #define PITMODE 0x43 #define PITCONST 1193180L #define KBCTRL 0x61 #define NEW70H 1 static float tick_per_ms = 1.024; static float ms_per_tick = 0.9765625; static char far *event; static unsigned char flag70h = 0; static void interrupt(*old70h) (__CPPARGS); volatile unsigned long int ticks_70h; void init70h(void) { union REGS regs; struct SREGS sregs; unsigned int event_seg, event_off; if (flag70h != NEW70H) { old70h = getvect(IRQ8); setvect(IRQ8, new70h); event_seg = FP_SEG(event); event_off = FP_OFF(event); regs.x.ax = SET_EVENT; sregs.es = event_seg; regs.x.bx = event_off; regs.x.cx = LARGEST; regs.x.dx = LARGEST; int86x(0x15, ®s, ®s, &sregs); flag70h = NEW70H; } } void quit70h(void) { union REGS regs; if (flag70h == NEW70H) { regs.x.ax = CANCEL_EVENT; int86(0x15, ®s, ®s); setvect(IRQ8, old70h); flag70h = 0; } } void interrupt new70h(__CPPARGS) { disable(); ticks_70h++; enable(); old70h(); } unsigned long time70h(unsigned long start, unsigned long stop) { unsigned long duration, millisec; if (stop < start) return 0; else { duration = stop - start; millisec = duration * ms_per_tick; return millisec; } } void delay70h(unsigned int delayms) { unsigned long int delaybegin = 0; unsigned long int delayend = 0; unsigned int delaytick; if (flag70h == NEW70H) { delaytick = delayms * tick_per_ms; delaybegin = ticks_70h; do { delayend = ticks_70h; } while ((delayend - delaybegin) < delaytick); } else { delaytick = delayms * 0.0182065; biostime(0, (long) &delaybegin); do { biostime(0, (long) &delayend); } while ((delayend - delaybegin) < delaytick); } } void sound70h(int freq, int duration) { int byte; unsigned int freq1; freq1 = PITCONST / freq; outportb(PITMODE, 0xb6); byte = (freq1 & 0xff); outportb(PIT2, byte); byte = (freq1 >> 8); outportb(PIT2, byte); byte = inportb(KBCTRL); outportb(KBCTRL, (byte | 3)); delay70h(duration); outportb(KBCTRL, (byte & 0xfc)); } ************************************************************************* tcint70.h #ifdef __cpluspls # define __CPPARGS ... #else # define __CPPARGS void #endif void interrupt new70h(__CPPARGS); void init70h(void); void quit70h(void); unsigned long time70h(unsigned long, unsigned long); void delay70h(unsigned int); void sound70h(int, int); extern volatile unsigned long int ticks_70h;