↑ ↓ ← → Kenneth Spencer <kas kaspencer.com>
writes:
Re.: Compiling C programs from previous Zortech/Symantec compilers
We have several programs written in previous versions of
Zortech/Symantec C (no C++), which we wish to convert to compile
with Digital Mars. (Zortech C/C++ and Symantec C/C++ are
predecessors of Digital Mars).
Most of the programs consist of several C modules compiled and
linked with a Large Memory model: we have used this approach
because the resultant executables have been found to run on all
versions of Windows from 3.1 through 9/98/2k/2k3/XP and now Vista.
We are trying to use the IIDE for these projects, which have
previously been compiled and linked at the command line. However,
when we try to compile the programs in DM, we encounter rather too
many errors and issues, and wondered whether anyone may be able to
help.
ISSUE 1
we do not seem to be able to change the Memory Model for
compilation: it is restricted to "Flat".
ISSUE 2
Issue two occurs early in the compilation of the first module and
results in the compiler ceasing to process code after the include
statement:
#include <drivinit.h>
However the compiler continues to count lines (even though the
count grossly exceeds the line count of our projects!) until it
fails and issues the report:
============ complier output report ===========================
sc Persw.c -p -mn -o+time -WA -3 -a8 -c -H -HO- -
IC:\SW_Tools\DigiMars\include -oPersw.obj
nbytes = 65520, ph_maxsize = 65520
Fatal Error: C:\SW_Tools\DigiMars\include\win32\drivinit.h(2):
internal error ph 1817
Lines Processed: 645805 Errors: 1 Warnings: 0
Build failed
================================================================
ISSUE 3
If we remove the Include line which generates ISSUE 2, the
compiler stops and reports many problems relating to a need to
introduce explicit casts into our code. This is code that compiles
and runs correctly under the previous versions of ZTC.
Some examples of the code, and the errors generated are:
============= CODE SAMPLE A =====================================
BOOL InitApplication (hInstance)
HANDLE hInstance;
{
int count;
WNDCLASS wc;
wc.style = NULL;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (hInst, "PERSWIcon");
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject (LTGRAY_BRUSH);
wc.lpszMenuName = "PERSWMenu";
wc.lpszClassName = "PERSWClass";
return (RegisterClass (&wc));
}
==================== COMPILER OUTPUT =========================
sc Persw.c -p -mn -o+time -WA -3 -a8 -c -H -HO- -
IC:\SW_Tools\DigiMars\include -oPersw.obj
Error: K:\PERS-SYS\DigiMarsTest\Persw.c(850): need explicit cast
to convert
K:\PERS-SYS\DigiMarsTest\Persw.c(850): from: void *
K:\PERS-SYS\DigiMarsTest\Persw.c(850): to : unsigned
==============================================================
This error references the line:
wc.style = NULL;
in the above code.
There are many errors of this type, for example:
================ CODE SAMPLE B ===============================
Referencing the line below from CODE SAMPLE A above:
wc.lpfnWndProc = MainWndProc;
we have defined the function MainWindowProc as:
long FAR PASCAL MainWndProc (HWND, unsigned, WORD, LONG);
in our include file for the Project.
This generates the error:
Error: K:\PERS-SYS\DigiMarsTest\Persw.c(851): need explicit cast
to convert
K:\PERS-SYS\DigiMarsTest\Persw.c(851): from: long (*std func)(void
*,unsigned ,unsigned short ,long )
K:\PERS-SYS\DigiMarsTest\Persw.c(851): to : long (*std func)(void
*,unsigned ,unsigned ,long )
So can anyone advise us on any of these issues, or do we have to
go back to our old compiler and forget about trying to use the
latestr versions of Digital Mars ?
Regards and thanks in advance,
Kenneth Spencer
↑ ↓ ← → Walter Bright <newshound1 digitalmars.com>
writes:
Kenneth Spencer wrote:
We are trying to use the IIDE for these projects, which have
previously been compiled and linked at the command line. However,
when we try to compile the programs in DM, we encounter rather too
many errors and issues, and wondered whether anyone may be able to
help.
I'd first try to compile with DM's command line before moving to the IDDE.
ISSUE 1
we do not seem to be able to change the Memory Model for
compilation: it is restricted to "Flat".
Use the 16 bit IDDE, which is \dm\bin\scw.exe.
ISSUE 2
Issue two occurs early in the compilation of the first module and
results in the compiler ceasing to process code after the include
statement:
#include <drivinit.h>
However the compiler continues to count lines (even though the
count grossly exceeds the line count of our projects!) until it
fails and issues the report:
============ complier output report ===========================
sc Persw.c -p -mn -o+time -WA -3 -a8 -c -H -HO- -
IC:\SW_Tools\DigiMars\include -oPersw.obj
nbytes = 65520, ph_maxsize = 65520
Fatal Error: C:\SW_Tools\DigiMars\include\win32\drivinit.h(2):
internal error ph 1817
Lines Processed: 645805 Errors: 1 Warnings: 0
Build failed
================================================================
Try copying the project to another one, then try deleting source code
until what is causing the problem is isolated.
ISSUE 3
If we remove the Include line which generates ISSUE 2, the
compiler stops and reports many problems relating to a need to
introduce explicit casts into our code. This is code that compiles
and runs correctly under the previous versions of ZTC.
Some examples of the code, and the errors generated are:
============= CODE SAMPLE A =====================================
BOOL InitApplication (hInstance)
HANDLE hInstance;
{
int count;
WNDCLASS wc;
wc.style = NULL;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (hInst, "PERSWIcon");
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject (LTGRAY_BRUSH);
wc.lpszMenuName = "PERSWMenu";
wc.lpszClassName = "PERSWClass";
return (RegisterClass (&wc));
}
==================== COMPILER OUTPUT =========================
sc Persw.c -p -mn -o+time -WA -3 -a8 -c -H -HO- -
IC:\SW_Tools\DigiMars\include -oPersw.obj
Error: K:\PERS-SYS\DigiMarsTest\Persw.c(850): need explicit cast
to convert
K:\PERS-SYS\DigiMarsTest\Persw.c(850): from: void *
K:\PERS-SYS\DigiMarsTest\Persw.c(850): to : unsigned
==============================================================
This error references the line:
wc.style = NULL;
in the above code.
What is the type of wc.style?
There are many errors of this type, for example:
================ CODE SAMPLE B ===============================
Referencing the line below from CODE SAMPLE A above:
wc.lpfnWndProc = MainWndProc;
we have defined the function MainWindowProc as:
long FAR PASCAL MainWndProc (HWND, unsigned, WORD, LONG);
in our include file for the Project.
This generates the error:
Error: K:\PERS-SYS\DigiMarsTest\Persw.c(851): need explicit cast
to convert
K:\PERS-SYS\DigiMarsTest\Persw.c(851): from: long (*std func)(void
*,unsigned ,unsigned short ,long )
K:\PERS-SYS\DigiMarsTest\Persw.c(851): to : long (*std func)(void
*,unsigned ,unsigned ,long )
Looks like the type of WORD is different from your header to your source
code. I suggest this is an issue from trying to compile 16 bit code as
32 bit code.
So can anyone advise us on any of these issues, or do we have to
go back to our old compiler and forget about trying to use the
latestr versions of Digital Mars ?
Regards and thanks in advance,
Kenneth Spencer
↑ ↓
← → Arjan Knepper <arjan ask.me.to>
writes:
Kenneth Spencer wrote:
Re.: Compiling C programs from previous Zortech/Symantec compilers
We have several programs written in previous versions of
Zortech/Symantec C (no C++), which we wish to convert to compile
with Digital Mars. (Zortech C/C++ and Symantec C/C++ are
predecessors of Digital Mars).
Most of the programs consist of several C modules compiled and
linked with a Large Memory model: we have used this approach
because the resultant executables have been found to run on all
versions of Windows from 3.1 through 9/98/2k/2k3/XP and now Vista.
Do you really want to keep support in for win 3.1 (16bits)? Otherwise I
would advise to go for the "flat" one used on 32/64 bits platforms.
We are trying to use the IIDE for these projects, which have
previously been compiled and linked at the command line. However,
when we try to compile the programs in DM, we encounter rather too
many errors and issues, and wondered whether anyone may be able to
help.
ISSUE 1
we do not seem to be able to change the Memory Model for
compilation: it is restricted to "Flat".
The memory model depends on the project "target -> platform" type. All
win32 platform types support only the "flat" memory model.
To use other memory models choose "target -> platform" to be windows 3.1
or dos.
ISSUE 2
Issue two occurs early in the compilation of the first module and
results in the compiler ceasing to process code after the include
statement:
#include <drivinit.h>
However the compiler continues to count lines (even though the
count grossly exceeds the line count of our projects!) until it
fails and issues the report:
============ complier output report ===========================
sc Persw.c -p -mn -o+time -WA -3 -a8 -c -H -HO- -
IC:\SW_Tools\DigiMars\include -oPersw.obj
nbytes = 65520, ph_maxsize = 65520
Fatal Error: C:\SW_Tools\DigiMars\include\win32\drivinit.h(2):
internal error ph 1817
Lines Processed: 645805 Errors: 1 Warnings: 0
Build failed
================================================================
Cool....
Stop using the precompiled header options or specify a additional
parameter in the bin/sc.ini file
[Environment]
CFLAGS=-HP299
Which icreases the max amount of memory the PH might consume.
ISSUE 3
If we remove the Include line which generates ISSUE 2, the
compiler stops and reports many problems relating to a need to
introduce explicit casts into our code. This is code that compiles
and runs correctly under the previous versions of ZTC.
Some examples of the code, and the errors generated are:
============= CODE SAMPLE A =====================================
BOOL InitApplication (hInstance)
HANDLE hInstance;
{
int count;
WNDCLASS wc;
wc.style = NULL;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon (hInst, "PERSWIcon");
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject (LTGRAY_BRUSH);
wc.lpszMenuName = "PERSWMenu";
wc.lpszClassName = "PERSWClass";
return (RegisterClass (&wc));
}
==================== COMPILER OUTPUT =========================
sc Persw.c -p -mn -o+time -WA -3 -a8 -c -H -HO- -
IC:\SW_Tools\DigiMars\include -oPersw.obj
Error: K:\PERS-SYS\DigiMarsTest\Persw.c(850): need explicit cast
to convert
K:\PERS-SYS\DigiMarsTest\Persw.c(850): from: void *
K:\PERS-SYS\DigiMarsTest\Persw.c(850): to : unsigned
==============================================================
This error references the line:
wc.style = NULL;
in the above code.
IRRC This is due to the fact the compiler defaults to C99 which does not
allow implicit cast from void * anymmore. There has been a request by
someone else to provide a compiler swicth to turn this off. Search the
newsgroup archieves for this.
There are many errors of this type, for example:
================ CODE SAMPLE B ===============================
Referencing the line below from CODE SAMPLE A above:
wc.lpfnWndProc = MainWndProc;
we have defined the function MainWindowProc as:
long FAR PASCAL MainWndProc (HWND, unsigned, WORD, LONG);
in our include file for the Project.
This generates the error:
Error: K:\PERS-SYS\DigiMarsTest\Persw.c(851): need explicit cast
to convert
K:\PERS-SYS\DigiMarsTest\Persw.c(851): from: long (*std func)(void
*,unsigned ,unsigned short ,long )
K:\PERS-SYS\DigiMarsTest\Persw.c(851): to : long (*std func)(void
*,unsigned ,unsigned ,long )
The functions signatures don't match on the second arg. unsigned (
32bits) vs unsigned short ( 16 bits )
So can anyone advise us on any of these issues, or do we have to
go back to our old compiler and forget about trying to use the
latestr versions of Digital Mars ?
I would not go back but persist in making it work with the latest DMC
compiler(s) by adjusting the code and/or compiler flags.
Arjan Knepper