www.digitalmars.com         C & C++   DMDScript  

c++.stl.sgi - Problem using STL in Makefile

reply Tat Chan <Tat_member pathlink.com> writes:
Hi,
I managed to compile a project using DMC v8.29n that was originally compiled
using Symantec C++ v7.2 I am now trying to add some STL code to the original 
C-only code.

My setup is:
Windows 2000 SP2
Location of DM:  c:\dev\dm

In one of the files, I just added a "#include <vector>" to see if the new code
will compile. I am using the SGI STL library that came with the DMC download.

I get the following errors:

SMAKE  Program Maintenance Utility (Console) Version 7.50
Copyright (c) 1994-1995 Innovative Data Concepts Incorporated
Copyright (c) 1994-2001 Digital Mars
All Rights Reserved

c:\dev\dm\bin\sc -r -Ju -mn -3 -a8 -C -S -g -gd  -D_CONSOLE -D_MT -D_WIN
DOWS -DHAVE_USLEEP -DSQUID_CFG_DIR=\"./config\" -DSQUID_WGT_DIR=\"./wgtfiles\"
-DSQUID_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI    -DHAVE_CAP
I=1 -If:\capi20\include   -c -opsquid\main.obj main.c
c:\dev\dm\bin\sc -r -Ju -mn -3 -a8 -C -S -g -gd  -D_CONSOLE -D_MT -D_WIN
DOWS -DHAVE_USLEEP -DSQUID_CFG_DIR=\"./config\" -DSQUID_WGT_DIR=\"./wgtfiles\"
-DSQUID_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI    -DHAVE_CAP
I=1 -If:\capi20\include   -c -opsquid\init.obj init.c
c:\dev\dm\bin\sc -r -Ju -mn -3 -a8 -C -S -g -gd  -D_CONSOLE -D_MT -D_WIN
DOWS -DHAVE_USLEEP -DSQUID_CFG_DIR=\"./config\" -DSQUID_WGT_DIR=\"./wgtfiles\"
-DSQUID_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI    -DHAVE_CAP
I=1 -If:\capi20\include   -c -opsquid\console.obj console.c
inline void __stl_throw_range_error(const char*) {}
^
C:\DEV\DM\BIN\..\stl\stl_range_errors.h(61) : Error: '=', ';' or ',' expected
}
^
C:\DEV\DM\BIN\..\stl\stl_relops.h(39) : Error: identifier or '( declarator )' ex
pected
template <class _Tp>
^
C:\DEV\DM\BIN\..\stl\stl_relops.h(41) : Error: '=', ';' or ',' expected
}
^
C:\DEV\DM\BIN\..\stl\stl_relops.h(44) : Error: identifier or '( declarator )' ex
pected
template <class _Tp>
^
C:\DEV\DM\BIN\..\stl\stl_relops.h(46) : Error: '=', ';' or ',' expected
Fatal error: too many errors
--- errorlevel 1
SMAKE fatal error: command "c:\dev\dm\bin\sc" returned with error code 1
Stopping.
SMAKE fatal error: command "smake" returned with error code 2
Stopping.

The -D macro definitions and compiler command line options were from the
original Makefile using Symantec C++ v7.2 (which DMC compiled successfully,
without the "#include <vector>" line). The file console.c contains the "#include
<vector> line".

I find this weird as I have written a test case using strings and vectors which
compiles(and runs) fine using "sc -osym.exe sym.cpp".

Do I need to make any #defines or set up the STL library before using it?

Thanks,

Tat
Sep 02 2002
parent reply "Walter" <walter digitalmars.com> writes:
Your makefile is compiling a C++ program as if it were a C program. Try
using -cpp, and remove the -Ju.

"Tat Chan" <Tat_member pathlink.com> wrote in message
news:al1iaj$2hc6$1 digitaldaemon.com...
 Hi,
 I managed to compile a project using DMC v8.29n that was originally

 using Symantec C++ v7.2 I am now trying to add some STL code to the

 C-only code.

 My setup is:
 Windows 2000 SP2
 Location of DM:  c:\dev\dm

 In one of the files, I just added a "#include <vector>" to see if the new

 will compile. I am using the SGI STL library that came with the DMC

 I get the following errors:

 SMAKE  Program Maintenance Utility (Console) Version 7.50
 Copyright (c) 1994-1995 Innovative Data Concepts Incorporated
 Copyright (c) 1994-2001 Digital Mars
 All Rights Reserved

 c:\dev\dm\bin\sc -r -Ju -mn -3 -a8 -C -S -g -gd  -D_CONSOLE -D_MT -D_WIN

\"
 -DSQUID_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI    -DHA

 I=1 -If:\capi20\include   -c -opsquid\main.obj main.c
 c:\dev\dm\bin\sc -r -Ju -mn -3 -a8 -C -S -g -gd  -D_CONSOLE -D_MT -D_WIN

\"
 -DSQUID_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI    -DHA

 I=1 -If:\capi20\include   -c -opsquid\init.obj init.c
 c:\dev\dm\bin\sc -r -Ju -mn -3 -a8 -C -S -g -gd  -D_CONSOLE -D_MT -D_WIN

\"
 -DSQUID_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI    -DHA

 I=1 -If:\capi20\include   -c -opsquid\console.obj console.c
 inline void __stl_throw_range_error(const char*) {}
 ^
 C:\DEV\DM\BIN\..\stl\stl_range_errors.h(61) : Error: '=', ';' or ','

 }
 ^
 C:\DEV\DM\BIN\..\stl\stl_relops.h(39) : Error: identifier or '(

 pected
 template <class _Tp>
 ^
 C:\DEV\DM\BIN\..\stl\stl_relops.h(41) : Error: '=', ';' or ',' expected
 }
 ^
 C:\DEV\DM\BIN\..\stl\stl_relops.h(44) : Error: identifier or '(

 pected
 template <class _Tp>
 ^
 C:\DEV\DM\BIN\..\stl\stl_relops.h(46) : Error: '=', ';' or ',' expected
 Fatal error: too many errors
 --- errorlevel 1
 SMAKE fatal error: command "c:\dev\dm\bin\sc" returned with error code 1
 Stopping.
 SMAKE fatal error: command "smake" returned with error code 2
 Stopping.

 The -D macro definitions and compiler command line options were from the
 original Makefile using Symantec C++ v7.2 (which DMC compiled

 without the "#include <vector>" line). The file console.c contains the

 <vector> line".

 I find this weird as I have written a test case using strings and vectors

 compiles(and runs) fine using "sc -osym.exe sym.cpp".

 Do I need to make any #defines or set up the STL library before using it?

 Thanks,

 Tat

Sep 03 2002
parent reply Tat Chan <Tat_member pathlink.com> writes:
Hi Walter,

I added the -cpp flag and removed the -Ju flag from the compiler and got the
following result:


SMAKE  Program Maintenance Utility (Console) Version 7.21
Copyright (c) 1994-1995 Innovative Data Concepts Incorporated
Copyright (c) 1994-1995 Symantec Corporation
All Rights Reserved

*** Building PSTN specific SQUID modules ***
smake CFG= CFGDEFS=" " -fpstnslib.mak

SMAKE  Program Maintenance Utility (Console) Version 7.21
Copyright (c) 1994-1995 Innovative Data Concepts Incorporated
Copyright (c) 1994-1995 Symantec Corporation
All Rights Reserved

c:\dev\dm\bin\sc -r -mn -3 -a8 -cpp -S -g  -D_CONSOLE -D_MT -D_WINDOWS -
DHAVE_USLEEP -DSQUID_CFG_DIR=\"./config\" -DSQUID_WGT_DIR=\"./wgtfiles\"  -DSQUI
D_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI -If:\capi20\include
-c -ocapi.obj capi.c
Info = CAPI_GET_CMSG(CMSG, ccid->Appl_Id);
^
capi.c(192) : Error: need explicit cast to convert
from: unsigned
to  : enum MESSAGE_EXCHANGE_ERROR
--- errorlevel 1
SMAKE fatal error: command "c:\dev\dm\bin\sc" returned with error code 1
Stopping.
SMAKE fatal error: command "smake" returned with error code 2
Stopping.

The cast error now appears in a file that has not been modified and was
successfully compiled previously without the -cpp flag. MESSAGE_EXCHANGE_ERROR
is defined in another library's header file.

Is there a compiler switch to avoid making an explicit cast (I couldn't find one
in the documentation)?

Or should I change the Makefile to only use the -cpp flag on files that have C++
code as the original app was written in pure C?


thanks,

Tat

In article <al2n9l$2g6v$1 digitaldaemon.com>, Walter says...
Your makefile is compiling a C++ program as if it were a C program. Try
using -cpp, and remove the -Ju.

Sep 03 2002
parent reply "Walter" <walter digitalmars.com> writes:
You've run into a difference between C++ and C semantics. Just put the cast
in, and it will compile with both C and C++. -Walter

"Tat Chan" <Tat_member pathlink.com> wrote in message
news:al3j6a$2ftr$1 digitaldaemon.com...
 Hi Walter,

 I added the -cpp flag and removed the -Ju flag from the compiler and got

 following result:


 SMAKE  Program Maintenance Utility (Console) Version 7.21
 Copyright (c) 1994-1995 Innovative Data Concepts Incorporated
 Copyright (c) 1994-1995 Symantec Corporation
 All Rights Reserved

 *** Building PSTN specific SQUID modules ***
 smake CFG= CFGDEFS=" " -fpstnslib.mak

 SMAKE  Program Maintenance Utility (Console) Version 7.21
 Copyright (c) 1994-1995 Innovative Data Concepts Incorporated
 Copyright (c) 1994-1995 Symantec Corporation
 All Rights Reserved

 c:\dev\dm\bin\sc -r -mn -3 -a8 -cpp -S -g  -D_CONSOLE -D_MT -D_WINDOWS -

QUI

lude
 -c -ocapi.obj capi.c
 Info = CAPI_GET_CMSG(CMSG, ccid->Appl_Id);
 ^
 capi.c(192) : Error: need explicit cast to convert
 from: unsigned
 to  : enum MESSAGE_EXCHANGE_ERROR
 --- errorlevel 1
 SMAKE fatal error: command "c:\dev\dm\bin\sc" returned with error code 1
 Stopping.
 SMAKE fatal error: command "smake" returned with error code 2
 Stopping.

 The cast error now appears in a file that has not been modified and was
 successfully compiled previously without the -cpp flag.

 is defined in another library's header file.

 Is there a compiler switch to avoid making an explicit cast (I couldn't

 in the documentation)?

 Or should I change the Makefile to only use the -cpp flag on files that

 code as the original app was written in pure C?


 thanks,

 Tat

 In article <al2n9l$2g6v$1 digitaldaemon.com>, Walter says...
Your makefile is compiling a C++ program as if it were a C program. Try
using -cpp, and remove the -Ju.


Sep 03 2002
parent reply Tat Chan <Tat_member pathlink.com> writes:
Hi Walter,

I am now getting a different kind of error ... I assume it is to do with the
different meanings of "static" in C and C++


SMAKE  Program Maintenance Utility (Console) Version 7.21
Copyright (c) 1994-1995 Innovative Data Concepts Incorporated
Copyright (c) 1994-1995 Symantec Corporation
All Rights Reserved

c:\dev\dm\bin\sc -cpp -r -mn -3 -a8 -S -g  -D_CONSOLE -D_MT -D_WINDOWS
DHAVE_USLEEP -DSQUID_CFG_DIR=\"./config\" -DSQUID_WGT_DIR=\"./wgtfiles\"  -DSQ
D_LOG_DIR=\"./logs\" -DSAVESAMP_DIR=\"./savesamp\" -DUSE_GUI    -DHAVE_CAPI=1
f:\capi20\include   -c -opsquid\console.obj console.c
static logid_t *                        clog = &console_logid;
^
console.c(74) : Error: 'clog' previously declared as something else
It was declared as: ostream_withassign
It is now declared: logid_t*
}
^
console.c(1130) : Warning 18: implied return of set_dc_input_sym at closing '}
does not return value
}
^
console.c(1152) : Warning 18: implied return of set_rate_input_sym at closing
' does not return value
--- errorlevel 1
SMAKE fatal error: command "c:\dev\dm\bin\sc" returned with error code 1
Stopping.
SMAKE fatal error: command "smake" returned with error code 2
Stopping.


I had a look at the code, and this is the first time the static variable clog is
defined. It is pointing to another static variable, console_logid, which is of
type "static logid_t".


Also, the 2 error warnings are because the function prototypes are meant to
return static ints, but there is no explicit call to return any values.

In article <al3jps$2i6h$1 digitaldaemon.com>, Walter says...
You've run into a difference between C++ and C semantics. Just put the cast
in, and it will compile with both C and C++. -Walter

Sep 03 2002
parent reply Tat Chan <Tat_member pathlink.com> writes:
whoops ... clog is defined in include/IOSTREAM.H as "extern ostream_withassign
clog", so I have to change the declaration of clog in my code
Sep 03 2002
parent "Walter" <walter digitalmars.com> writes:
I suggest it may be easier to port the code to C++ first, and afterwards try
to mix in STL.

"Tat Chan" <Tat_member pathlink.com> wrote in message
news:al3om2$31fl$1 digitaldaemon.com...
 whoops ... clog is defined in include/IOSTREAM.H as "extern

 clog", so I have to change the declaration of clog in my code

Sep 04 2002