Microsoft KB Archive/216977: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - "<" to "<")
Line 12: Line 12:
<div id="TitleRow">
<div id="TitleRow">


= <span id="KB216977"></span>You receive an &quot;error C2233:'&lt;Unknown&gt;' : arrays of objects containing zero-size arrays are illegal&quot; error message in Visual C++ when you compile a template class that contains a data member =
= <span id="KB216977"></span>You receive an &quot;error C2233:'<Unknown&gt;' : arrays of objects containing zero-size arrays are illegal&quot; error message in Visual C++ when you compile a template class that contains a data member =




Line 49: Line 49:
<div class="errormessage">
<div class="errormessage">


error C2233: '&lt;Unknown&gt;' : arrays of objects containing zero-size arrays are illegal
error C2233: '<Unknown&gt;' : arrays of objects containing zero-size arrays are illegal


</div>
</div>
Line 78: Line 78:
=== Steps to Reproduce Behavior ===
=== Steps to Reproduce Behavior ===


<pre class="codesample">template &lt;int k&gt;
<pre class="codesample">template <int k&gt;
class A
class A
{
{
Line 84: Line 84:
};
};


template &lt;int h, int j&gt;
template <int h, int j&gt;
class B   
class B   
{
{
     A&lt;h&gt; y[j];
     A<h&gt; y[j];
};
};
                 </pre>
                 </pre>
Line 94: Line 94:
=== Workaround ===
=== Workaround ===


<pre class="codesample">template &lt;int k&gt;
<pre class="codesample">template <int k&gt;
class A
class A
{
{
Line 105: Line 105:
     }
     }
};
};
template &lt;int h, int j&gt;
template <int h, int j&gt;
class B   
class B   
{
{
     A&lt;h&gt; y[j];
     A<h&gt; y[j];
};
};
                 </pre>
                 </pre>

Revision as of 08:56, 21 July 2020

Knowledge Base


You receive an "error C2233:'<Unknown>' : arrays of objects containing zero-size arrays are illegal" error message in Visual C++ when you compile a template class that contains a data member

Article ID: 216977

Article Last Modified on 1/19/2007



APPLIES TO

  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++ 6.0 Standard Edition



This article was previously published under Q216977

SYMPTOMS

When you compile a template class that contains a data member that is an array of a second template class, and the second class contains a data member that is an array, and the size of both arrays is dependent on a template parameter, you may receive the following error:

error C2233: '<Unknown>' : arrays of objects containing zero-size arrays are illegal

RESOLUTION

Use a pointer instead of an array. Allocate the space for the array in the constructor, and deallocate the space for the array in the destructor.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug has been fixed in Microsoft Visual Studio 6.0 Service Pack 5 (SP5).

To download service pack 5, see the Visual Studio Product Updates page on the following Microsoft Web site at: [1]

MORE INFORMATION

Steps to Reproduce Behavior

template <int k>
class A
{
    char x[k];
};

template <int h, int j>
class B  
{
     A<h> y[j];
};
                


Workaround

template <int k>
class A
{
    char *x;
    A() {
        x = new char[k];
    }
    ~A() {
        delete[] x;
    }
};
template <int h, int j>
class B  
{
     A<h> y[j];
};
                

Keywords: kbqfe kbhotfixserver kbbug kbcompiler kbcpponly kbfix kbvc600fix KB216977