안녕하세요.
올려주신 코드는 도스용 C 에서만 컴파일됩니다. bios.h, conio.h, dos.h 모두 도스용 파일입니다. 먼저 Borland/Turbo C++ 3.1 이하인 도스용 컴파일러인지 확인하세요. C++ 빌더에 콘솔 모드로 프로그래밍 할 수 있긴하나 위의 bios.h 같이 메모리를 직접 건드리는 함수들은 지원하지 않습니다. 또한 far 와 같이 16비트 메모리모드에서 필요한 키워드도 지원하지 않습니다.
도스용 C를 사용하신다면 옵션에서 C++ 옵션을 보시면 C++로만 컴파일 하는 옵션이 있습니다. 그 옵션이 체크되어 있으면 CPP확장자만 C++로 컴파일하는것으로 바꾸세요.
그리고 역시 옵션에 소스 형식을 정하는게 있는데 혹시 다은 ANSI C나 UNIX C로 되어 있다면 Borland C로 바꿔주세요.
"Cannot conver 'void *' to 'int *' in function main()" <- 이 오류는 (int far *) 를 MK_FP 앞에 붙여주면 해결됩니다. 이 오류메세지에 far 키워드가 없는걸 보니 far 키워드를 무시하고 컴파일 된것 같은데 혹시 옵션에 32비트 메모리 모델로 컴파일하도록 되어 있지 않은지 살펴보세요.
그외에는 헤더파일이 있고 헤더파일 내용이 제대로 있다면 아래와 같은 오류가 생길리가 없겠는데요...
다시 해보시고 글 남겨주세요.
천승환 님이 쓰신 글 :
: 안녕하세요.
:
: Borland C++의 Help에 나오는 예제인데, 컴파일 해보면,
:
: Cannot conver 'void *' to 'int *' in function main()
: Call to undefined function 'bioscom' in function main()..
: Call to undefined function 'cprintf' in function main()..
:
: 이런 에러가 나옵니다.
:
: 분명히 include 되있는데 왜 안되죠?
:
: Turbo C++를 설치해서 해봐도 똑같네요..
:
: OS는 WinXP Pro입니다.
:
: 조언 부탁드립니다.
:
: -----------------------------------------------------------
: /* bioscom example */
:
:
:
: /*
: This example can be used to communicate between
: two PCs via a null modem cable.
: The example is specific to COM1. The appropriate values
: for COM2 are included in this example for the convenience
: of switching the code to work with COM2.
:
: */
: #include <bios.h>
: #include <conio.h>
: #include <dos.h>
:
: #define DTR 0x01 // Data Terminal Ready
: #define RTS 0x02 // Ready To Send
: #define COM1PORT 0x0000 // Pointer to Location of COM1 port
: #define COM2PORT 0x0002 // Pointer to Location of COM2 port
: #define COM1 0
: #define COM2 1
: #define DATA_READY 0x100
: #define FALSE 0
: #define TRUE !FALSE
:
: #define SETTINGS ( 0xE0 | 0x00 | 0x02 | 0x00) // 9600,N,7,1
:
: int main( void )
: {
: int in,
: out,
: status,
: DONE = FALSE,
: far *RS232_Addr;
:
: /* Determine port location of COM1.
: 0x40:0x00 = COM1 I/O port address
: 0x40:0x02 = COM2 I/O port address
: */
: RS232_Addr = MK_FP( 0x0040, COM1PORT );
: if( !*RS232_Addr )
: return -1;
:
: bioscom( 0, SETTINGS, COM1 );
: cprintf( "... BIOSCOM [ESC] to exit ...\n" );
:
: while( !DONE )
: {
: /* Reset DTR and RTS to prepare for send/receive of
: next character.
: */
: outportb( *RS232_Addr + 4, DTR | RTS );
:
: /* Get status of com port.
: */
: status = bioscom( 3, 0, COM1 );
:
: if( status & DATA_READY )
:
: /* There's a character on the port. Get it and echo.
: */
:
: if( (out = bioscom( 2, 0, COM1 ) & 0x7F) != 0 )
: putch( out );
:
: if( kbhit() )
:
: /* Key has been struck. Get it and send to port.
: */
: if( (in = getch()) == '\x1B' )
:
: /* User pressed ESCAPE. Don't send to port.
: */
: DONE = TRUE;
:
: else
:
: /* Send character to com port.
: */
: bioscom( 1, in, COM1 );
: }
: return 0;
: }
:
:
:
|