title: How do you std::vector in XCode + C++?
body: <p>For various reasons (and I assure you they are valid, so no "use Cocoa" talk please), I must work with XCode, C++, OpenGL, OpenCL (with a little GLUT on the side) to rebuild a few graphics demos on Mac (coming from XP + Visual Studio 2005 development). The project was built as a Command Line Tool using "c++ stdc++".</p>
  
  <p>My Program.h file connects my shader objects together, compiles, links, and otherwise prepares them for use as OpenGL shader programs. Contained within this file are the following relevant lines of code:</p>
  
  <pre><code>#include &lt;vector&gt;
  using std::vector;
  </code></pre>
  
  <p>and within the private section of the class:</p>
  
  <pre><code>vector&lt;int&gt; shaderHandles;
  </code></pre>
  
  <p>and when adding shader handles:</p>
  
  <pre><code>shaderHandles.push_back(shaderHandle);
  </code></pre>
  
  <p>and finally, when using the pushed shader handles:</p>
  
  <pre><code>for (int s = 0; s &lt; (int) shaderHandles.size(); s++)
  {
      glAttachShader(handle, shaderHandles[s]);
  }
  </code></pre>
  
  <p>In all my experience and research, there's nothing wrong with these lines within C++. However, when compiling (whether debug or release, so it's not related to the <code>_GLIBCXX_DEBUG</code> problem), the following 4 errors are generated:</p>
  
  <pre><code>/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/stl_bvector.h:916: error: 'size' is not a member of 'std'
  /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/stl_bvector.h:961: error: 'size' is not a member of 'std'
  /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/vector.tcc:350: error: '__old_size' is not a member of 'std'
  /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/vector.tcc:453: error: '__old_size' is not a member of 'std'
  </code></pre>
  
  <p>Also, the file that links to stl_bvector.h and vector.tcc is:</p>
  
  <pre><code>/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/vector
  </code></pre>
  
  <p>Thus far, numerous Google searches have turned up nothing. All this code works flawlessly on Windows. Worse, if I replace the above code with the list equivalents:</p>
  
  <pre><code>#include &lt;list&gt;
  using std::list;
  </code></pre>
  
  <p>and,</p>
  
  <pre><code>list&lt;int&gt; shaderHandles;
  </code></pre>
  
  <p>and,</p>
  
  <pre><code>for (list&lt;int&gt;::iterator s = shaderHandles.begin(); s != shaderHandles.end(); s++)
  {
      glAttachShader(handle, *s);
  }
  </code></pre>
  
  <p>The program works as expected.</p>
  
  <p>But one can't blame this ENTIRELY on the vector implementation, because the following program:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using std::vector;
  
  int main (int argc, char * const argv[])
  {
      vector&lt;int&gt; test;
  
      test.push_back(1);
      test.push_back(2);
      test.push_back(3);
  
      test.clear();
      return 0;
  }
  </code></pre>
  
  <p>Works with no problems.</p>
  
  <p>I'll be happy to provide more information as necessary.</p>
  
  <p>Please don't tell me I should use Cocoa/Objective-C; it's not really an option right now. And while yes, I can use lists to accomplish this functionality, other parts of my demo are not so easy to rework.</p>