Error compile KE2043 with OpenWatcom
Closed this issue · 21 comments
Look, difficult, I don't know how they managed to compile this, someone changed the code to be able to compile with OpenWatcom, I'm getting compilation errors in sys.c and dsk.c for now, it doesn't come out of it. They are actually alerts that are not letting it compile. If anyone can test or compare the previous files to see what was removed I would appreciate it. One of the most famous compilers of the DOS Watcom era, if not the best, being left for last, it is easy to configure to be able to compile with nasm and watcom.
:-
:- batch file that is included in all other batch files for configuration |
---|
:-****************************************************************
:- NOTICE! You must edit and rename this file to CONFIG.BAT! *
:-****************************************************************
:-*********************************************************************
:- determine your compiler settings |
---|
:- you have to |
:- search for XNASM - and set the path for NASM |
:- search for COMPILER - and set your compiler |
:- search for ??_BASE - and set the path to your compiler |
:- |
:-********************************************************************* |
:-**********************************************************************
:-- define NASM executable - remember - it should not be protected
:- mode DJGPP version if you're using Windows NT/2k/XP to compile
:- because DJGPP-nasm crashes when using protected mode Borland's
:- make under Windows NT/2k/XP
:-**********************************************************************
set XNASM=nasm
:**********************************************************************
:- define your COMPILER type here, pick one of them
:**********************************************************************
:- Turbo C 2.01
:- set COMPILER=TC2
:- Turbo C++ 1.01
:- set COMPILER=TURBOCPP
:- Turbo C 3.0
:- set COMPILER=TC3
:- Borland C 3.1
:- set COMPILER=BC3
:- Borland C
:- set COMPILER=BC5
:- Microsoft C
:- set COMPILER=MSCL8
:- Watcom C
set COMPILER=WATCOM
:-**********************************************************************
:-- where is the BASE dir of your compiler(s) ??
:-**********************************************************************
:- set TC2_BASE=c:\tc201
:- set TP1_BASE=c:\tcpp
:- set TC3_BASE=c:\tc3
:- set BC3_BASE=c:\bc
:- set BC5_BASE=c:\bc5
:- set MS_BASE=c:\msvc
:- if WATCOM maybe you need to set your WATCOM environment variables
:- and path
:- if not %WATCOM% == \ goto watcom_defined
:- set WATCOM=c:\watcom
set PATH=%PATH%;%WATCOM%\binw
:watcom_defined
:-**********************************************************************
:- where is UPX and which options to use?
:-**********************************************************************
SET XUPX=
:- set XUPX=upx --8086 --best
:- or use set XUPX=
:- if you don't want to use it
:-**********************************************************************
:- (optionally) which linker to use:
:- (otherwise will be determined automatically) |
---|
:- WARNING TLINK needs to be in your PATH! |
:-********************************************************************** |
:- Turbo Link
:- set XLINK=tlink /m/c/s/l
:- Microsoft Link
:- set XLINK=d:\qb\link /ma
:- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo
:- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink)
set XLINK=..\utils\wlinker /ma /nologo
:- set path for Turbo Link - use OLDPATH to restore normal path
:- set OLDPATH=%PATH%
:- set PATH=%PATH%;%TC2_BASE%
:**********************************************************************
:* optionally define your MAKE type here, if not then
:* it will be automatically determined, pick one of them
:* use MS nmake if you want to compile with MSCL
:**********************************************************************
:- Borland MAKE
:- set MAKE=%TC2_BASE%\make
:- Watcom MAKE in MS mode
set MAKE=%WATCOM%\binw\wmake /ms
:- Microsoft MAKE
:- set MAKE=%MS_BASE%\bin\nmake /nologo
:**********************************************************************
:* select your default target: required CPU and what FAT system to support
:**********************************************************************
SET XCPU=86
:- set XCPU=86
:- set XCPU=186
:- set XCPU=386
SET XFAT=32
:- set XFAT=16
:- set XFAT=32
:- Give extra compiler DEFINE flags here
:- such as -DDEBUG : extra DEBUG output
:- -DDOSEMU : printf output goes to dosemu log
:- set ALLCFLAGS=-DDEBUG
:-
:- |
---|
Watcom and Nasm must be in the default drive C:\ try to reproduce and you will see the error, this does not occur in 2042...
Oh, don't forget to declare the path of nasm in autoexec.bat or fdauto.bat:
SET PATH=C:\WATCOM\BINW;%dosdir%\BIN;\DJGPP\BIN;\NASM;
and for watcom add this
SET DJGPP=C:\DJGPP\DJGPP.ENV
SET INCLUDE=C:\WATCOM\H
SET WATCOM=C:\WATCOM
SET EDPATH=C:\WATCOM\EDDAT
SET WWINHELP=C:\WATCOM\BINW
SET WIPFC=C:\WATCOM\WIPFC
To compile on a real machine you must be using the base install of freedos that comes with all the base components.
Please help, for one person it is difficult.
Hmm. Spoken like a true bot (IMO).
Thanks for the compliment 🦾, but I can only test with other compilers after passing this compilation error, in fact something has changed, between version 2042 and 2043 OpenWatcom stopped compiling Kernel FreeDOS. If you try to debug you will have more success in getting the result. But it's hard for one person to do just that. If there was any way we could work this out together, I'd be happy. 🙂🤝
Please provide the exact error messages. It will tell which line causes your error and should say what the error is. Without this, adjusting the build/source to fix will be unlikely. Open Watcom is one of my primary compilers for the kernel, so it should work. Which version do you use? 1.9 and latest 2.0 git versions should work. Though my 2.0 git version is getting older, so maybe a recent change in the compiler found an error or introduced a new warning.
First of all, I'm not a bot, okay? I'm a human friend, and I like old stuff, mostly FreeDOS for being open source, second MS-DOS for the new license and third not least OpenDOS which tried to be something like open source but stumbled on the license but still valid , but I still prefer FreeDOS in addition to programming, compiling, and debugging. I've been doing this for years alone, but now that I'm showing up here, it's necessary to share data, and that's important. After this, let's try to virtualize the sound, too bad the first attempt at this failed, and ended up hiding code and I didn't strictly follow the license, because all the projects used should benefit from the improved code.
I'm just looking for the error message or at least where the build failed for you, otherwise I don't know where to even start looking for your build issue. Note that building often works on one OS and fails on others. :-( What OS are you building on? DOS, Win9x, NT pre6, NT6+, Linux,...?
So let's go, there are two files that the compilation does not pass with OpenWatcom 1.9 or 2.0, it simply manages to compile normally with the commercial version Watcom 10.6 and 11.0, which is beside the point. So when compiling OW 2.0 I get this error about dsk.c, DSK.log:
dsk.c(176): Warning! W106: Constant out of range - truncated
dsk.c(176): Note! I2003: source conversion type is 'unsigned int'
dsk.c(176): Note! I2004: target conversion type is 'int'
dsk.c(179): Warning! W106: Constant out of range - truncated
dsk.c(179): Note! I2003: source conversion type is 'unsigned int'
dsk.c(179): Note! I2004: target conversion type is 'int'
dsk.c(468): Warning! W106: Constant out of range - truncated
dsk.c(468): Note! I2003: source conversion type is 'unsigned int'
dsk.c(468): Note! I2004: target conversion type is 'short'
dsk.c(517): Warning! W106: Constant out of range - truncated
dsk.c(517): Note! I2003: source conversion type is 'unsigned int'
dsk.c(517): Note! I2004: target conversion type is 'short'
dsk.c(558): Warning! W106: Constant out of range - truncated
dsk.c(558): Note! I2003: source conversion type is 'unsigned int'
dsk.c(558): Note! I2004: target conversion type is 'short'
dsk.c(673): Warning! W106: Constant out of range - truncated
dsk.c(673): Note! I2003: source conversion type is 'unsigned int'
dsk.c(673): Note! I2004: target conversion type is 'short'
dsk.c(722): Warning! W106: Constant out of range - truncated
dsk.c(722): Note! I2003: source conversion type is 'unsigned int'
dsk.c(722): Note! I2004: target conversion type is 'short'
dsk.c(796): Warning! W106: Constant out of range - truncated
dsk.c(796): Note! I2003: source conversion type is 'unsigned int'
dsk.c(796): Note! I2004: target conversion type is 'short'
dsk.c(822): Warning! W106: Constant out of range - truncated
dsk.c(822): Note! I2003: source conversion type is 'unsigned int'
dsk.c(822): Note! I2004: target conversion type is 'short'
dsk.c(826): Warning! W106: Constant out of range - truncated
dsk.c(826): Note! I2003: source conversion type is 'unsigned int'
dsk.c(826): Note! I2004: target conversion type is 'short'
dsk.c(856): Warning! W106: Constant out of range - truncated
dsk.c(856): Note! I2003: source conversion type is 'unsigned int'
dsk.c(856): Note! I2004: target conversion type is 'short'
dsk.c(875): Warning! W106: Constant out of range - truncated
dsk.c(875): Note! I2003: source conversion type is 'unsigned int'
dsk.c(875): Note! I2004: target conversion type is 'short'
dsk.c(878): Warning! W106: Constant out of range - truncated
dsk.c(878): Note! I2003: source conversion type is 'unsigned int'
dsk.c(878): Note! I2004: target conversion type is 'short'
dsk.c(881): Warning! W106: Constant out of range - truncated
dsk.c(881): Note! I2003: source conversion type is 'unsigned int'
dsk.c(881): Note! I2004: target conversion type is 'short'
dsk.c(884): Warning! W106: Constant out of range - truncated
dsk.c(884): Note! I2003: source conversion type is 'unsigned int'
dsk.c(884): Note! I2004: target conversion type is 'short'
dsk.c(888): Warning! W106: Constant out of range - truncated
dsk.c(888): Note! I2003: source conversion type is 'unsigned int'
dsk.c(888): Note! I2004: target conversion type is 'short'
dsk.c(890): Warning! W106: Constant out of range - truncated
dsk.c(890): Note! I2003: source conversion type is 'unsigned int'
dsk.c(890): Note! I2004: target conversion type is 'short'
dsk.c(892): Warning! W106: Constant out of range - truncated
dsk.c(892): Note! I2003: source conversion type is 'unsigned int'
dsk.c(892): Note! I2004: target conversion type is 'short'
dsk.c(894): Warning! W106: Constant out of range - truncated
dsk.c(894): Note! I2003: source conversion type is 'unsigned int'
dsk.c(894): Note! I2004: target conversion type is 'short'
dsk.c(896): Warning! W106: Constant out of range - truncated
dsk.c(896): Note! I2003: source conversion type is 'unsigned int'
dsk.c(896): Note! I2004: target conversion type is 'short'
These warning messages indicate that type conversions have occurred where a constant of type unsigned int was truncated (that is, had its high-order bits discarded) when being converted to an int or short type. The specific W106 warning message is issued by the Watcom compiler and usually indicates that a data loss occurred during the conversion.
For example, consider the following code snippet:
unsigned int x = 50000;
int y = x;
In this case, the constant 50000 is of type unsigned int, which is an unsigned type that can store values greater than zero. However, when assigning this value to a variable of type int, which is a signed type and has a smaller range, truncation occurs, resulting in a loss of data.
These warnings are issued to warn of the possibility of data loss during conversion. It's important to review these conversions and consider whether the loss of data is acceptable or whether you need to make any code modifications to avoid potential issues.
It doesn't matter if I'm using the virtualbox system, and windows, or Linux, or natively... I've tested them all, and it still gives errors.
already in sys.c I get this error in the following lines:
1488: bs = (struct bootsectortype *)&oldboot;
1614: bs = (struct bootsectortype *)&newboot;
1624: bs32 = (struct bootsectortype32 *)&newboot;
1784: bs32 = (struct bootsectortype32 *)&newboot;
That is, there are pointer conversion operations taking place in these parts of the sys.c code. The warning "W115: &array may not produce intended result" is triggered when you use the "&" operator on an array and do a pointer type conversion.
These pointer conversions may be valid in certain contexts, but the warning is suggesting that there may be unexpected behavior when performing this conversion, possibly due to the type difference between the original variable and the target pointer.
So I removed the & and the error is gone, at least here... but dsk.c is still having problems as mentioned, or we can ignore the warning of a possible error and trample everything in the mkfile/watcom.mak file on lines 25 and 26 , and at the end of the command add -w0 which means I will be instructing the Watcom compiler not to issue warnings during compilation, but of course this is not recommended.
I hope you can follow me... I can help you debug faster using dosbox instead.
already in sys.c I get this error in the following lines:
1488: bs = (struct bootsectortype *)&oldboot; 1614: bs = (struct bootsectortype *)&newboot; 1624: bs32 = (struct bootsectortype32 *)&newboot; 1784: bs32 = (struct bootsectortype32 *)&newboot;
That is, there are pointer conversion operations taking place in these parts of the sys.c code. The warning "W115: &array may not produce intended result" is triggered when you use the "&" operator on an array and do a pointer type conversion.
This was indeed fixed by @PerditionC via commit c152d55
@4nd3r50ncr is it essential for you to compile 2043? Otherwise you might try to compile the master branch. Perhaps there are fixes beyond the one posted above.
I'll help you debug in DOSBOX, everything will be easier for any project you do, and you want to develop something.
1º Install DOSBOX.
2º Create a folder in C:\ of your disk, or in the folder /home/name/ in your linux called DOS. Inside the DOS folder create two more separate folders called C, and the other E.
3º Inside the "C" folder create a file called DOSBOX.BAT
4º Add the following lines to the DOSBOX.BAT file:
@echo OFF
SET TZ=EDT
C:
MOUNT E "C:\DOS\E"
If it's Linux do:
@echo OFF
SET TZ=EDT
C:
MOUNT E "\home\nameofuser\DOS\E"
5º Edit the file dosbox-0.74-3.conf in windows C:\Users\NameOfUser\AppData\Local\DOSBox, in Linux it is in the home folder if I'm not mistaken in .dosbox in the conf folder, and add it at the end of the file. conf the following lines:
@mount C "C:\DOS\C" -FREESIZE 1024
@if EXIST C:\DOSBOX.BAT CALL C:\DOSBOX.BAT
@if EXIST C:\AUTOEXEC.BAT CALL C:\AUTOEXEC.BAT
on linux it would look like this:
@mount C "\home\nameofuser\DOS\C" -FREESIZE 1024
@if EXIST C:\DOSBOX.BAT CALL C:\DOSBOX.BAT
@if EXIST C:\AUTOEXEC.BAT CALL C:\AUTOEXEC.BAT
note: put the cpu cycles from auto to MAX for, to make things faster...
6º Now download and extract the entire system using 7zip or any other into the folder C:\DOS\E or on Linux \home\nameofuser\DOS\E the "LITE" image of freedos.
7º open the dosbox and enter the E folder, with the command that we know... and execute the installation with the SETUP command and do the total installation of freedos.
8º Done, now just install the compilers.
9º Or of course do everything on a real machine using freedos on a usbstick.
is it essential for you to compile 2043? Otherwise you might try to compile the master branch. Perhaps there are fixes beyond the one posted above.
Wanting to get away from the errors, I'm running the branch too.
Look, I don't know, we need to stop and analyze it, it's okay there are other compilers, but we can't let it go, we should analyze it better, the problem is that I'm just having time today, and because I'm off today , but it's not demeaning but every compiler that can compile freedos is important, OW is no different. It's been a while since I've worked on projects, the last one is Haiku. And I'm not a robot as mentioned by tkchia 😂.
With regard to truncation, apart from short and the others as I mentioned earlier. But related to this one I will give an example.
Suppose you have a variable called age declared as an unsigned int. This variable is used to store a person's age.
unsigned int age = 300;
Now, imagine that you want to convert this age to an int (integer) data type. However, an int has a smaller range of possible values compared to an unsigned int. An int can store values from -32768 to 32767 (assuming a 16-bit int).
int convertedage = age;
In that case, a truncation error will occur. The age value, 300, exceeds the allowable range for an int. Truncation happens when the value is converted and only the most significant bits that fit in the int are kept, discarding the additional bits that represent the surplus part.
Therefore, the compiler will issue a warning of the type "Constant out of range - truncated", indicating that the conversion will result in a truncation, and will also provide additional information about the type of conversion involved.
It is important to be aware of these errors and be careful when converting between data types to avoid missing important information or unexpected behavior in the code.
It's good here, we'll talk. Until later. 👍
Hello Mr. (?) Anderson,
Erm, you still seem like a bot to me, and I claim my £5. Or, at the very least, you are trying your darnedest best to look and sound like a bot.
For one thing, I am sure the value 300 can fit very comfortably in a 16-bit signed int
variable. As you yourself pointed out, int
has a range of -32,768 to +32,767.
I am not (yet) sure what exactly you are up to. But I suppose we will find out soon.
Thank you!
tkchia, I gave an example, and definitely not a solution, as you can see, the variable I mentioned was an example, of an assumption, of a possible cause of error in the lines I mentioned, as you mentioned the 16-bit variable has the size from -32,768 to +32,767, unless you define a specific variable size, I gave a small example as a way of trying to understand the compilation error in the file, and again, I'm not a robot. I'm trying to help, I gave examples of how you can debug quickly, test it first, try to do the same, and you'll see what I'm talking about, however I ask you to stop trying to be a hater, that kind of thing only exists nowadays in the communities, one or the other trying to bank on the best, I've been testing and playing with the system for some time now, so please respect me, this is my hobby, not my profession. I hope you don't feel offended, hugs friend.
Hello Mr. (?) Anderson,
I still do not know what you are up to. But it seems that whatever it is you are doing, you are doing it wrong.
I gave a small example as a way of trying to understand the compilation error in the file, and again, I'm not a robot.
Cutting-and-pasting a (wrong) "explanation" of an error message from what is obviously an AI model — and passing it off as your own "understanding" — is a dumb idea. If you do not understand why, then we cannot help you.
Thank you!
No offense, but you're being an idiot, and you haven't even tried to reproduce the compilation error I'm getting, I'm using DOSBOX as my emulation area and that's perfect for me, what I wrote was on the uncopied finger, or you don't did you understand? I'll tell you exactly what it is, it's been a couple of years or so since I haven't been able to compile with OW, or are you offended that you're not using your 16-bit gcc compiler? I think I'm lay? I will try to solve the problem myself. Thanks, and don't bug me.
Hello Mr. (?) Anderson,
Duuude.
Thank you!
I love you HATER, that's why the community is divided, unfortunately, kisses and hugs