Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FAQ. Раздел IV. Compiler specific. Подраздел #C. Watcom. (редакция от 2

2 views
Skip to first unread message

FAQ Daemon

unread,
Jan 20, 2010, 4:00:02 PM1/20/10
to
IV. Compiler specific.
#C. Watcom.

������ ��ģ� Kirill Joss, 2:463/59.29, jo...@bk.ru.


>WATCOM C/C++ lite FAQ v3.13 06 Feb 2007

>> 001. ��� ����� ������������ �� ������?
> Q: ��� ����� ������������ �� ������?

A: � ��������. ��� ��� ���� � ���� ������ �������� � ����p������, �p���
����� ��p����p���.

>> 002. ��� � ��� ��������, ������ �� �������, � ���� ������?
> Q: ��� � ��� ��������, ������ �� �������, � ���� ������?

A: ������ ����� - �������� ������������, ������ Watcom C/C++ 10/11 �
OpenWatcom v1.x ������������ � ��������� ������� �����.

>> 003. � ���� ������, ����� ����� ����������??
> Q: � ���� ������, ����� ����� ����������??

A: H���� � �����������:
-------------------------------
#include <stdio.h>
main() {
puts("Hello, world");
}
-------------------------------
��� ���������� ����� ������������:
wcl hello.c - ��� DOS/16
wcl386 /l=dos4gw hello.c - ��� DOS4GW

>> 004. � ������� ���������� ����������, � ��� �� ��������.
> Q: � ������� ���������� ����������, � ��� �������� ��������, ���
> ���������� ��������� � ������������ �����, ��� ������? � ��-�� �����
> ����� � ���������� ��� ���������� ������ ������������ - ��� ��������
> ���������?

A1: ���������� ����� ����� ��������� ��������� ������� WLSYSTEM.LNK,
�������� ��������� ������ �����, �� ��������� ��� ����� 1 ��� 2 ��,
���� ���� ������������ ��� ��������, ��������� ����� ���� ���������
������� �� �����. ��� ����������� ���������� ���������� ������� �����
� 16 ��� 32 ���������. ���� �� ��������� ��� �����������, �����
��������� ���� ���� �������� ;)
A2: ���� ��� ������: ��� .com �������� (������ ������ tiny) ������
������ ����� � ������� ������� ������, ��� ����� ����� ������������
������������������� ���������� _stacklen (�.�. � ���� ����� ��������
��������� �����:
extern unsigned _stacklen = <������ ������ ����� � ������>;
� ������ �������, ��� ���������� ������������� ������ ��� ������ ������
tiny, �������� � ������ ������� ������ ��� ���������� ����������,
��������� �� ��, ��� �������� ������. ��� ���������: � Turbo/Borland C
���������� stklen �������� � ����� ������ ������.

>> 005. ������ ������ ���� ������������� �� � ������ �����.
> Q: � ���������� � ���, ��� ������ ������ ���� ������������� �� � ������
> �����, � � �����, � ����-�� ���?

A: ��������� ����� ������������� ������� � ������� �������� ����������
� ������ �������, ���� ��� ��� ������, ��������� ���������� �����
��������, ���� ����� - ����� ����.

>> 006. ������ ���� ��� �� ������ '_' �����.
> Q: � ������� ������������ �� ���������, �� ������ ������������� �������,
> � ������ ���� �� �� ���, �� �� ������ "_" �����, ��� ��� ���������?

A: ����� ��������:
#pragma aux ASMFUNC "_*";
� ��������� ��� ���� ������� ���:
#pragma aux (ASMFUNC) foo;
#pragma aux (ASMFUNC) bar;
������, ���� ����������� �������� - ������ "^", ������� �������������,
��� ��� ���� ������������� � ������� �������, ��������:
#pragma aux myfunc "^";
�������� � ��������� � ��������� ����� ������ �� "MYFUNC".

>> 007. ���� ����������, ��������� ������� �����������...
> Q: ���� ����������, ��������� ������� �����������, ��� ���������
> ������ ��������� �������� ����� ������� � ������� ���� "_" �������,
> � �� �����? ���� ������ ������ - ��� ����� �� �������� ;(

A: H���� � ����� ��������� ������� ������ ������� ��� cdecl, ���
���� ��������� ����� ������������ ����� ���� � ��� ������� �����
������������ ���������.

>> 008. �����, ����� ������ Watcom ��������� ��������� ����� ����.
> Q: ��� ������� ��� ���� � ��������� ������� Watcom ��������� ���������
> �� ����� ��������, � ����� ���� (� ��������� ���������� �� tasm'e, ��������)?

A: ������������ cdecl. H��p���p:
extern void cdecl dummy( int );

>> 009. ��� ������ ������������ �������?
> Q: � ���� ��������� ������������ inline ��������� � ��������������,
> ����� �� � ��������� �� �������� ��� ��������?
> ��� ������ ������������ ������� � ���������?

A1: �������� ���:
----------------------------------------------------
unsigned short swap_bytes ( unsigned short word );
#pragma aux swap_bytes = "xchg ah, al" \
parm [ ax ] \
value [ ax ];
----------------------------------------------------
����� parm ��p������� � ����� p�����p� �� ��p������ ��������, �����
value - � ����� ����p������. ����� ������������ �����. ���� �����
modify - ����� ������� ��� ���� ������� (��� �������) �� ����������
������, � �p����� ������ �� ��� ���� p�����p�. �� ����� ����������p�
����� ����. �p������ �� ����������, �� ���� ����, �� �������p �p���p���
����.
A2: H������ � ������ 11.0 �������� � _asm { ... }

>> 010. ��� ������ ���������� exe-����?
> Q: ��� ������ ���������� exe-����?

A1: �������� WLINK, ������ ���������:
---------------------------------------
name ...
system ...
debug all
option ...\
option ... - ����� ����� � �� ����
option .../
...
file ...
file ...
...
libpath ... - � ����� ����.
library .../
---------------------------------------
��������: wlink name myprog system dos4gw debug all file myprog
A2: ���, ������: wlink n myprog sys dos4gw d a f myprog

>> 011. ��� ����� ms2wlink � ����� ��� �y���?
> Q: ��� ����� ms2wlink � ����� ��� �y���?

A1: ��� ��� ��� ��� ��p������ � ���������������� �. �p���p���������
������ LINK � WLINK.
A2: ��a ������� ��������� ��������� ������ MS LINK � ������ � �����������
����� ��������� ��� wlink, ������� ����� ������������� � ���� � ������ WLINK.
������ �������������: "ms2wlink %1 %2 %3 %4 %5 | wlink". �ݣ ������:
------------------------------------------------------
ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9>kernel.lnk
echo op map,statics,verbose,eliminate,vfremoval>>kernel.lnk
wlink @kernel.lnk
-------------------------------------------------------

>> 012. � ��� ��� � Watcom`e ��p�������� stdin/stdout/stderr �p��p����?
> Q: � ��� ��� � Watcom`e ��p�������� stdin/stdout/stderr �p��p����?

A: � ������ ���p��� ���� stdout � stderr? ��� ��� ������ - �������
�� ����-������. ������� dup() ��� ����� �� �������.

Q: ����: printf ( "*" );, � �� �p��� ������ �� ��������. ��� ������?
Q: ����: printf ( "*" );, � �� �p��� ������ �� ��������. ��� ������?
A1: � ������p�� ansi, ��������� � �����, ޣ����� ��p�������� ��� ������
����p����������� ������ stdin/stdout/stderr ���, ���� �� �������� ��� ������,
�� ��p������� �������� ��������� �� ��p����� ����p������� stdout/stdin, ������
�p���� ���-�������p� ������ �� ����p����� stdout ������, ��� ���� ��p������.
�p������� ����� ��p��� � ������ �������� '\n', ������ �p� ��������� �����
������� �p�������� flush ��� line buffered ������. ������� ���: ��������
����p������ ��� ������ '\n' � ������ ������. ����� fflush(stdout) �����, ����
��p����. ����p������ ���������� setbuf(stdout,NULL) ���
setvbuf(stdout,NULL,_IONBF,0).
A2: ������ ����, ������� ��� �������� �������� � ���� ������ � ����������
BriefLZ:
---------------------------------------------------------------------------
#ifdef __WATCOMC__
/* Unlike BC, which unbuffers stdout if it is a device, OpenWatcom 1.2
line buffers stdout; this prevents "rotator" trick based on output
of "\r" and writing new line over previous. To make rotator work
we unbuffer stdout manually:
*/
setbuf (stdout, NULL);
#endif
---------------------------------------------------------------------------

>> 013. ��� �������� ��p����� � ���������������� �p��������?
> Q: ��� �������� ��p����� � ���������������� �p��������?

A1: ���� ����������� �������� �������� -- ������ ������� �����
����������, ��������: void foo( int bar, char* ).
A2: #pragma off(unreferenced)
A3: ��������� ������:

#ifndef NU
#ifdef __cplusplus
#ifdef __BORLANDC__
#define NU( ARG ) (ARG)
#else
#define NU( ARG ) (void)(ARG)
#endif
#else
#define NU( ARG ) (ARG)=(ARG)
#endif
#endif

A4: ��� ������, �������� ���������� �p�����������, ��������p�� p�������
/*ARGSUSED*/ ��p�� ��p��������� �������.
A5: �������� ������������� TC/TC++/BC/MSC/OW ��������, ��� ���������� ������:
#define UNREFERENCED_PARAMETER(x) (void)(x)
void f (int arg) {
UNREFERENCED_PARAMETER (arg);

>> 014. ��� ������� � �������-� �� ������?
> Q: � ��� ����� ����� �� �������-�, ������ ����� ����������� ��
> ������, ��� ��� ����� ����� ��� �������?

A1: ������� ����� �������� ��������, �� ������ ����� ��� ��������
������� ��� ���. �����������, ��� � ��� ������� �������� �
��������� ��������. H����� ����� � ��������� int -> short :)
A2: ������ int �� short ����� ������ � ������, ���� ��������� �� 32-������
������, ��� �������� �� 16-������ ������ � ���� ������� ���. �������� �
������: OW��� ����������� ������������� � MSC � ��������� ����������
������������� BC. ������������� ��� �� �� ���.������ �����������, �� ��
������ �������, �� �� ��������, �� �� ����������� �����. ��� ��� �����
����-������� �������������� ��� BC ��������� ������ ����� ��������� ���
�������� �� OW ���������. :(

>> 015. ����� �� ��������� ��� ������ ��������� � OWL ��� TVision?
> Q: ����� �� ��������� ��� ������ ���������, ���������� �
> ����������� OWL ��� TVision?

A: OWL -- ������ ����� ���, ��������� �� �������� �� �����������
����������, ������� �� �������������� ������������ ������. ���
�������� TVision ���� ��������� ���������,
���������� diff� ��� �p���p�������� TV ��� GNU C++ - �������
���������� GVISION. ��� �� p����� p���� ��� �p������, �����������,
�� �� �p����� ��p� ���� ������� TV ������� ��� 32 ���� � ����
������.
����� �������� �� ��� ��p�� TV ��� Watcom C++.
��p��� - ��� ��p���� ��� ������� � dos4gw TV 1.0, �����������
�������� �����������.
���p�� - TVWATCOM.ZIP, 179k. ������
��-�������� ���� � ���������� �����+makefile. ���� ����������
����������� �������� - ����� ���������� ��� �������������� �����
��������.

>> 016. ��� �a �a��o�e pea���o�a�� _AX �� Borland?
> Q: � �e���� �� �a�-���y�� �a �a��o�e pea���o�a�� _AX �� Borland?
> � �o �epe�o�y �o� �e�o �����o�e�y, a �a� o�� a�����o ��a��c�.

A: ���� ���� _AX ����� �� read-only, �� ����� ������� �p��p����:
=== Cut ===
short reg_ax ( void ) ;

#define _AX reg_ax()

#pragma aux reg_ax = \
value [ax]

#if defined( __386__ ) || defined( __FLAT__ )
int reg_eax ( void ) ;

#define _EAX reg_eax()

#pragma aux reg_eax = \
value [eax]
// ����� �� ������������ �� ��������� - 16-������ ��� 32-������ �����
#define rAX reg_eax()
#else
#define rAX reg_ax()
#endif
=== Cut ===
� ���� ��� �����������, �� ����� �� ���������� � ������� ��� �p����
������ (�� ���� ���p�� ���� �p������ ��� inline-asm).

>> 017. ���p������� �p������, ����� ���� ����p��� ��������� �p����...
> Q: ���p������� �p������, ����� ���� ����p��� ��������� �p���� -
> ����� ������� ���������� ��������, � ����� ��p������ (���p���p
> ��������p��). �����p ������ �� �p���, ������������ � �p�������
> �������� � ������ ����� ���� �����.

A1: H� ����� ����� ���� ������:
��p�������� obj->wdisasm->.asm->wasm->������������ obj
� ������ ��� �������� ��� ������ wlink'�.
A2: ���� ��� ��p����� �p������ - ����� ����� tasm 3.2, � ��� �����
tasm 4.0, ��������� ��p�� ���, ��� ����� p����� ������������� ��
���������� �� ����� ������ �p������... ��� TASM32 5.3 :)
����� ����������� LZASM, NASM, FASM ...

>> 018. ��� ������� ����� �� ������������ OpenWatcom'a ?
> Q: ��� ������� ����� �� ������������ OpenWatcom'a ?

A: pkunzip -d <���������>, �� �������� ��� ������� ����� ������!

>> 019. OpenWatcom, ��������� �������� ���� ����������?
> Q: OpenWatcom, ��������� �������� ���� ����������?

A: ������. � ��� ��������� ����� �����, ������� ������� � Watcom-��
���������� ������, �� ������ ��� � ������������ ���������� (���
������������� �� �����������).

>> 020. OpenWatcom, ��������� �� ��������� �������, ����� �� ��� ������?
> Q: OpenWatcom, ��������� �� ��������� �������, ����� �� ��� ������?

A: ��� Open ������� ���� ������ ��� �������: release, pre-release (��������
������ ������� ����� �������) � daily-tarball (����� �������� ������
���������� �� ����� �����������). ���� ���, ������ � ���� - ��
daily-tarball �� � ����� ������ ������ ����������������� ���.

>> 021. ������ ������ �� �������.
> Q: ������ ������:

A:

Main site: http://www.openwatcom.org
News: news://news.openwatcom.org ��� � google groups

pchapin's Open Watcom Page: http://www.ecet.vtc.edu/~pchapin/OW/index.html
MN Watcom Page: http://howlingmad.gmxhome.de/
��������� ������������: http://cmeerw.org/prog/freecpp/
Paul Hsieh's WATCOM C/C++ Page: http://www.azillionmonkeys.com/qed/watcom.html
OS/2: http://www.mgreene.org/watcom/


0 new messages