www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - compiler bug?

↑ ↓ ← David Medlock <amedlock nospam.org> writes:
Hello.

Here is a snippet of the code I am compiling(part of a commercial package):

template<class T>
class Vector
{
   protected:
    U32 mElementCount;
    U32 mArraySize;
    T*  mArray;

    bool  resize(U32);
   public:
    Vector(const U32 initialSize = 0);
    Vector(const U32 initialSize, const char* fileName, const U32 lineNum);
    Vector(const char* fileName, const U32 lineNum);
    Vector(const Vector&);
    ~Vector();

    typedef T        value_type;
    typedef T&       reference;
    typedef const T& const_reference;

    typedef T*       iterator;
    typedef const T* const_iterator;
    typedef S32    difference_type;
    typedef U32    size_type;

...

    void insert(iterator, const T&);
    void erase(iterator);

...
    void push_front(const T&);
    void push_back(const T&);
    void pop_front();
    void pop_back();
...
};


z:/torque/engine\core/tVector.h(102) : Error: type qualifiers and static 
can only appear in outermost array of function parameter

z:/torque/engine\core/tVector.h(110) : Error: type qualifiers and static 
can only appear in outermost array of function parameter

z:/torque/engine\core/tVector.h(111) : Error: type qualifiers and static 
can only appear in outermost array of function parameter

line 102 is at the insert() function
line 110 is the push_front()
line 111 is the push_back()

What am I missing here?  This library compiles fine with gcc, 
metrowerks, and visual c++.

Thanks.
Jun 27 2004
↑ ↓ "Walter" <newshound digitalmars.com> writes:
Can you reproduce a complete code snippet I can compile to see the problem?
thanks!
Jun 27 2004
↑ ↓ David Medlock <amedlock nospam.org> writes:
Walter wrote:

 Can you reproduce a complete code snippet I can compile to see the problem?
 thanks!
 
 

 Can you reproduce a complete code snippet I can compile to see the 

 thanks!

Hello Walter. First thanks for the great compiler(and the quick response). The package I am compiling is Torque (www.garagegames.com). Since it is fairly tight-coupled(house of cards!) I have reproduced what is the jist of the problem(see code below). When you attempt to insert a static array as a template parameter it says no. This seems a reasonable error to me but gcc compiles it. I also tried to typedef ('block' type below), but that doesn't work either. Since I am in essence porting this engine to your compiler, I could make some changes, but I wanted your thought on it. Thanks again, David Medlock // begin code snippet template<class T>class Vector { public: void insert(T*, const T&) {;} }; typedef unsigned int U32; typedef unsigned int block[50]; int main( int argc, char** argv ) { Vector<U32[50]> int_vector; Vector<block> int_block_vector; }
Jun 28 2004
↑ ↓ "Walter" <newshound digitalmars.com> writes:
I can take it from here, thanks!
Jun 28 2004
↑ ↓ David Medlock <amedlock nospam.org> writes:
Walter wrote:
 I can take it from here, thanks!
 
 

Cool! Btw. not to pile anything else on you, but this also gives issues: int a = 0; if ( bool(a) ) a++; is the C++ cast of bool(x) valid? Thanks again, David Medlock
Jun 28 2004
↑ ↓ → "Walter" <newshound digitalmars.com> writes:
"David Medlock" <amedlock nospam.org> wrote in message
news:cbqf8b$2ohp$1 digitaldaemon.com...
 Walter wrote:
 I can take it from here, thanks!

Cool! Btw. not to pile anything else on you, but this also gives issues: int a = 0; if ( bool(a) ) a++; is the C++ cast of bool(x) valid?

Yes.
Jun 29 2004