www.digitalmars.com         C & C++   DMDScript  

c++ - Error compiling source which includes <new>

reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
The source file TestFile.cpp:

#include <new>

The command line:

dmc -c -Ar -Ae -Aa TestFile.cpp

The result:

class bad_alloc : public _STLP_EXCEPTION_BASE {
                                               ^
C:\Utilities\dm\bin\..\stlport\stlport\new(74) : Error: identifier expected
--- errorlevel 1
Aug 23 2010
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 The source file TestFile.cpp:
 
 #include <new>
 
 The command line:
 
 dmc -c -Ar -Ae -Aa TestFile.cpp
 
 The result:
 
 class bad_alloc : public _STLP_EXCEPTION_BASE {
                                               ^
 C:\Utilities\dm\bin\..\stlport\stlport\new(74) : Error: identifier expected
 --- errorlevel 1

It works when I try it.
Aug 23 2010
parent reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/23/2010 4:24 PM, Walter Bright wrote:
 Edward Diener wrote:
 The source file TestFile.cpp:

 #include <new>

 The command line:

 dmc -c -Ar -Ae -Aa TestFile.cpp

 The result:

 class bad_alloc : public _STLP_EXCEPTION_BASE {
 ^
 C:\Utilities\dm\bin\..\stlport\stlport\new(74) : Error: identifier
 expected
 --- errorlevel 1

It works when I try it.

Here is my sc.ini: [Version] version=8.52 [Environment] PATH=%PATH%;"% P%\..\bin" BIN="% P%\..\bin" INCLUDE="% P%\..\stlport\stlport";"% P%\..\include";"% P%\..\mfc\include";%INCLUDE% LIB="% P%\..\lib";"% P%\..\mfc\lib";%LIB% HELP="% P%\..\help" Would you please try it with that ? I have never changed anything in the stlport that comes with the installation disk.
Aug 23 2010
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 Would you please try it with that ? I have never changed anything in the 
 stlport that comes with the installation disk.

Sorry, I cannot reproduce it. BTW, you say installation disk. DMC has for some time only come as a download. Perhaps you are using something old?
Aug 24 2010
parent reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/24/2010 2:29 PM, Walter Bright wrote:
 Edward Diener wrote:
 Would you please try it with that ? I have never changed anything in
 the stlport that comes with the installation disk.

Sorry, I cannot reproduce it. BTW, you say installation disk. DMC has for some time only come as a download. Perhaps you are using something old?

When I bought dmc from you I used an installation disk you sent me. Subsequently I have used the downloads listed under "Updates for Digital Mars Development Systems" at http://www.digitalmars.com/download/freecompiler.html to upgrade the system. Was I supposed to do otherwise ? The problem I finally found was that the dmc configuration file, stlport/stlport/config/stl_dm.h, for the stlport 4.5.3 which originally comes with your compiler is wrong. The configuration defines a macro called _STLP_VENDOR_GLOBAL_STD which says that the "compiler-supplied standard library resides in global namespace, not std::". There may be other stlport configuration options there which are wrong but I think you have some responsibility in fixing that configuration file for end-users as you make changes to your compiler. Did I miss that somewhere ? Once I undefined that macro in the configuration file I was able to compile successfully.
Aug 24 2010
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 On 8/24/2010 2:29 PM, Walter Bright wrote:
 Edward Diener wrote:
 Would you please try it with that ? I have never changed anything in
 the stlport that comes with the installation disk.

Sorry, I cannot reproduce it. BTW, you say installation disk. DMC has for some time only come as a download. Perhaps you are using something old?

When I bought dmc from you I used an installation disk you sent me. Subsequently I have used the downloads listed under "Updates for Digital Mars Development Systems" at http://www.digitalmars.com/download/freecompiler.html to upgrade the system. Was I supposed to do otherwise ?

No, but perhaps there was a mistake somewhere in applying the patches.
 The problem I finally found was that the dmc configuration file, 
 stlport/stlport/config/stl_dm.h, for the stlport 4.5.3 which originally 
 comes with your compiler is wrong. The configuration defines a macro 
 called _STLP_VENDOR_GLOBAL_STD which says that the "compiler-supplied 
 standard library resides in global namespace, not std::". There may be 
 other stlport configuration options there which are wrong but I think 
 you have some responsibility in fixing that configuration file for 
 end-users as you make changes to your compiler. Did I miss that somewhere ?
 
 Once I undefined that macro in the configuration file I was able to 
 compile successfully.

It's still a mystery, as that macro remains defined in my copy and the compiles work.
Aug 24 2010
parent reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/24/2010 7:02 PM, Walter Bright wrote:
 Edward Diener wrote:
 On 8/24/2010 2:29 PM, Walter Bright wrote:
 Edward Diener wrote:
 Would you please try it with that ? I have never changed anything in
 the stlport that comes with the installation disk.

Sorry, I cannot reproduce it. BTW, you say installation disk. DMC has for some time only come as a download. Perhaps you are using something old?

When I bought dmc from you I used an installation disk you sent me. Subsequently I have used the downloads listed under "Updates for Digital Mars Development Systems" at http://www.digitalmars.com/download/freecompiler.html to upgrade the system. Was I supposed to do otherwise ?

No, but perhaps there was a mistake somewhere in applying the patches.
 The problem I finally found was that the dmc configuration file,
 stlport/stlport/config/stl_dm.h, for the stlport 4.5.3 which
 originally comes with your compiler is wrong. The configuration
 defines a macro called _STLP_VENDOR_GLOBAL_STD which says that the
 "compiler-supplied standard library resides in global namespace, not
 std::". There may be other stlport configuration options there which
 are wrong but I think you have some responsibility in fixing that
 configuration file for end-users as you make changes to your compiler.
 Did I miss that somewhere ?

 Once I undefined that macro in the configuration file I was able to
 compile successfully.

It's still a mystery, as that macro remains defined in my copy and the compiles work.

With _STLP_VENDOR_GLOBAL_STD defined, when I use the precompiler on source that only has #include <new>, I eventually see in the precompiled output: #line 64 "C:\Utilities\dm\bin\..\stlport\stlport\new" namespace std { class nothrow_t {}; extern const nothrow_t nothrow; #line 74 class bad_alloc : public ::exception { public: bad_alloc () { } bad_alloc(const bad_alloc&) { } bad_alloc& operator=(const bad_alloc&) {return *this;} ~bad_alloc () { } const char* what() const { return "bad alloc"; } }; } It is line 74 which gives the error. I believe it is because there is no ::exception class, since exception is actually std::exception, that the error message is occuring. Working my way back through why it says 'public ::exception' rather than 'std::exception" it is because _STLP_VENDOR_GLOBAL_STD is defined. The original says: "class bad_alloc : public _STLP_EXCEPTION_BASE {" where _STLP_EXCEPTION_BASE is: "# define _STLP_EXCEPTION_BASE _STLP_VENDOR_EXCEPT_STD::exception" where _STLP_VENDOR_EXCEPT_STD: "# ifdef _STLP_VENDOR_GLOBAL_EXCEPT_STD # define _STLP_VENDOR_EXCEPT_STD # else # define _STLP_VENDOR_EXCEPT_STD _STLP_VENDOR_STD # endif" where _STLP_VENDOR_GLOBAL_EXCEPT_STD is not defined for dmc, so where _STLP_VENDOR_STD: "# ifdef _STLP_VENDOR_GLOBAL_STD # define _STLP_VENDOR_STD # define _STLP_USING_VENDOR_STD # else # define _STLP_VENDOR_STD __std_alias # define _STLP_USING_VENDOR_STD _STLP_USING_NAMESPACE(_STLP_VENDOR_STD) // # define _STLP_USING_VENDOR_STD # endif" where _STLP_VENDOR_GLOBAL_STD is defined ( see beginning of my reply ), so finally we have _STLP_EXCEPTION_BASE becoming "::exception". If _STLP_VENDOR_GLOBAL_STD is not defined then we have above: "# define _STLP_VENDOR_STD __std_alias" and "namespace __std_alias = std;" so we have _STLP_EXCEPTION_BASE becoming "std::exception". I hope this adequately explains why the error is occuring on my system and can lead you to discover why it is working on yours and what is different.
Aug 24 2010
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 I hope this adequately explains why the error is occuring on my system 
 and can lead you to discover why it is working on yours and what is 
 different.

Did you receive the new copy of dmc?
Aug 25 2010
parent reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/25/2010 1:54 PM, Walter Bright wrote:
 Edward Diener wrote:
 I hope this adequately explains why the error is occuring on my system
 and can lead you to discover why it is working on yours and what is
 different.

Did you receive the new copy of dmc?

No. How should I received it ? Would you please explain what is different in my setup and yours so that I initially received the error but you did not ?
Aug 25 2010
parent Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 On 8/25/2010 1:54 PM, Walter Bright wrote:
 Edward Diener wrote:
 I hope this adequately explains why the error is occuring on my system
 and can lead you to discover why it is working on yours and what is
 different.

Did you receive the new copy of dmc?

No. How should I received it ?

I sent download instructions via email. Apparently, the address I sent it to was wrong. Can you please email me your address?
 Would you please explain what is different in my setup and yours so that 
 I initially received the error but you did not ?

I think it'll be easier to just diff the directories, if the new one works.
Aug 26 2010
prev sibling parent reply xharbour_deletethis telkom.net.id (Andi Jahja) writes:
On Mon, 23 Aug 2010 12:37:27 -0400, Edward Diener
<eddielee_no_spam_here tropicsoft.com> wrote:

The source file TestFile.cpp:

#include <new>

The command line:

dmc -c -Ar -Ae -Aa TestFile.cpp

The result:

class bad_alloc : public _STLP_EXCEPTION_BASE {
                                               ^
C:\Utilities\dm\bin\..\stlport\stlport\new(74) : Error: identifier expected
--- errorlevel 1

What about if you add -cpp to the switches? -- Andi
Aug 23 2010
parent Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/24/2010 12:06 AM, Andi Jahja wrote:
 On Mon, 23 Aug 2010 12:37:27 -0400, Edward Diener
 <eddielee_no_spam_here tropicsoft.com>  wrote:

 The source file TestFile.cpp:

 #include<new>

 The command line:

 dmc -c -Ar -Ae -Aa TestFile.cpp

 The result:

 class bad_alloc : public _STLP_EXCEPTION_BASE {
                                                ^
 C:\Utilities\dm\bin\..\stlport\stlport\new(74) : Error: identifier expected
 --- errorlevel 1

What about if you add -cpp to the switches? -- Andi

Same error.
Aug 24 2010