www.digitalmars.com         C & C++   DMDScript  

c++ - Error when compiling using dmc 8.52

reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
The following code:

#include <cwctype>

namespace std{
extern "C"{
#ifdef iswalnum
inline int (iswalnum)(wint_t i)
{ return iswalnum(i); }
#undef iswalnum
#else
#error iswalnum is undefined
#endif
} // extern "C"
} // namespace std

when compiled with dmc 8.52 using a sc.ini file of:

[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"

which puts stlport first among the includes, gives an error of:

C:\Programming\Programs\TestDMC\TestFile.cpp(8) : Error: 'iswalnum' is 
already defined
--- errorlevel 1

This appears to be a bug in dmc, and this bug is occuring when I try to 
run configuration tests for dmc for Boost.
Aug 18 2010
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 This appears to be a bug in dmc, and this bug is occuring when I try to 
 run configuration tests for dmc for Boost.

When I run it I get: Error test.cpp 7: iswalnum is undefined with or without -I\dm\stlport\stlport as a command line switch.
Aug 20 2010
parent reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/20/2010 2:18 PM, Walter Bright wrote:
 Edward Diener wrote:
 This appears to be a bug in dmc, and this bug is occuring when I try
 to run configuration tests for dmc for Boost.

When I run it I get: Error test.cpp 7: iswalnum is undefined with or without -I\dm\stlport\stlport as a command line switch.

Source file is called TestFile.cpp: #include <cwctype> namespace std{ extern "C"{ #ifdef iswalnum inline int (iswalnum)(wint_t i) { return iswalnum(i); } #undef iswalnum #else #error iswalnum is undefined #endif } // extern "C" } // namespace std The sc.ini is: [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" The command line is: dmc -c TestFile.cpp Result is: { return iswalnum(i); } ^ TestFile.cpp(7) : Error: 'iswalnum' is already defined --- errorlevel 1 Would you please try that exactly and see if it is the same ? The only version of dmc I have is 8.52, and I compiled from within the dmc bin directory just to make sure nothing changed from when i originally compiled it from outside the dmc bin directory with my PATH pointing to the bin directory. I am under Windows Vista Ultiante x_64. The version of StlPort under dmc says 4.5.3.
Aug 20 2010
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 { return iswalnum(i); }
 ^
 TestFile.cpp(7) : Error: 'iswalnum' is already defined
 --- errorlevel 1
 
 Would you please try that exactly and see if it is the same ?

Yes, I got the same error now. It's because it is already defined, on line 148 of \dm\stlport\stlport\config\stl_wince.h
Aug 20 2010
parent reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/20/2010 7:34 PM, Walter Bright wrote:
 Edward Diener wrote:
 { return iswalnum(i); }
 ^
 TestFile.cpp(7) : Error: 'iswalnum' is already defined
 --- errorlevel 1

 Would you please try that exactly and see if it is the same ?

Yes, I got the same error now. It's because it is already defined, on line 148 of \dm\stlport\stlport\config\stl_wince.h

The code is not defining the macro again. The error is bogus and should not be occurring.
Aug 20 2010
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 On 8/20/2010 7:34 PM, Walter Bright wrote:
 Edward Diener wrote:
 { return iswalnum(i); }
 ^
 TestFile.cpp(7) : Error: 'iswalnum' is already defined
 --- errorlevel 1

 Would you please try that exactly and see if it is the same ?

Yes, I got the same error now. It's because it is already defined, on line 148 of \dm\stlport\stlport\config\stl_wince.h

The code is not defining the macro again. The error is bogus and should not be occurring.

Right, it's defining a symbol again, not a macro.
Aug 20 2010
parent reply Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/21/2010 1:10 AM, Walter Bright wrote:
 Edward Diener wrote:
 On 8/20/2010 7:34 PM, Walter Bright wrote:
 Edward Diener wrote:
 { return iswalnum(i); }
 ^
 TestFile.cpp(7) : Error: 'iswalnum' is already defined
 --- errorlevel 1

 Would you please try that exactly and see if it is the same ?

Yes, I got the same error now. It's because it is already defined, on line 148 of \dm\stlport\stlport\config\stl_wince.h

The code is not defining the macro again. The error is bogus and should not be occurring.

Right, it's defining a symbol again, not a macro.

Are you claiming that this is an error in the particular C++ code presented, and that the dmc compiler is correct in flagging it as such ?
Aug 21 2010
parent reply Walter Bright <newshound2 digitalmars.com> writes:
Edward Diener wrote:
 On 8/21/2010 1:10 AM, Walter Bright wrote:
 Edward Diener wrote:
 On 8/20/2010 7:34 PM, Walter Bright wrote:
 Edward Diener wrote:
 { return iswalnum(i); }
 ^
 TestFile.cpp(7) : Error: 'iswalnum' is already defined
 --- errorlevel 1

 Would you please try that exactly and see if it is the same ?

Yes, I got the same error now. It's because it is already defined, on line 148 of \dm\stlport\stlport\config\stl_wince.h

The code is not defining the macro again. The error is bogus and should not be occurring.

Right, it's defining a symbol again, not a macro.

Are you claiming that this is an error in the particular C++ code presented, and that the dmc compiler is correct in flagging it as such ?

Consider: ============================================= H:\cbx\ztc>type test2.cpp inline int foo() { return 0; } inline int foo() { return 0; } H:\cbx\ztc>scppn test2 inline int foo() { return 0; } ^ test2.cpp(2) : Error: 'foo' is already defined ============================================== Is this not correct behavior?
Aug 21 2010
parent Edward Diener <eddielee_no_spam_here tropicsoft.com> writes:
On 8/21/2010 1:33 PM, Walter Bright wrote:
 Edward Diener wrote:
 On 8/21/2010 1:10 AM, Walter Bright wrote:
 Edward Diener wrote:
 On 8/20/2010 7:34 PM, Walter Bright wrote:
 Edward Diener wrote:
 { return iswalnum(i); }
 ^
 TestFile.cpp(7) : Error: 'iswalnum' is already defined
 --- errorlevel 1

 Would you please try that exactly and see if it is the same ?

Yes, I got the same error now. It's because it is already defined, on line 148 of \dm\stlport\stlport\config\stl_wince.h

The code is not defining the macro again. The error is bogus and should not be occurring.

Right, it's defining a symbol again, not a macro.

Are you claiming that this is an error in the particular C++ code presented, and that the dmc compiler is correct in flagging it as such ?

Consider: ============================================= H:\cbx\ztc>type test2.cpp inline int foo() { return 0; } inline int foo() { return 0; } H:\cbx\ztc>scppn test2 inline int foo() { return 0; } ^ test2.cpp(2) : Error: 'foo' is already defined ============================================== Is this not correct behavior?

OK, I see it now.
Aug 21 2010