tags:

views:

879

answers:

2

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++".

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:

#include <vector>
using std::vector;

and within the private section of the class:

vector<int> shaderHandles;

and when adding shader handles:

shaderHandles.push_back(shaderHandle);

and finally, when using the pushed shader handles:

for (int s = 0; s < (int) shaderHandles.size(); s++)
{
    glAttachShader(handle, shaderHandles[s]);
}

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 _GLIBCXX_DEBUG problem), the following 4 errors are generated:

/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'

Also, the file that links to stl_bvector.h and vector.tcc is:

/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/vector

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:

#include <list>
using std::list;

and,

list<int> shaderHandles;

and,

for (list<int>::iterator s = shaderHandles.begin(); s != shaderHandles.end(); s++)
{
    glAttachShader(handle, *s);
}

The program works as expected.

But one can't blame this ENTIRELY on the vector implementation, because the following program:

#include <iostream>
#include <vector>
using std::vector;

int main (int argc, char * const argv[])
{
    vector<int> test;

    test.push_back(1);
    test.push_back(2);
    test.push_back(3);

    test.clear();
    return 0;
}

Works with no problems.

I'll be happy to provide more information as necessary.

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.

A: 

Did you check the Mac SDK documentation, what functions do they declare for the vector class? Maybe you have set some compiler flags? Also you can do the same for the vector as you did for the list, using iterators to scan thru your vector.

caahab
Thanks for your quick response.No, I didn't check the Mac SDK documentation. I did read through the code a bit and found nothing out of the ordinary.No compiler flags.Yes, I can, but C was my first language, so I'm more used to array syntax, and frankly all that iterator stuff is so much to type.Thanks though, I *sigh* figured it out a few minutes after asking the question, despite spending hours prior on it.
Dwight
+2  A: 

I'm SO sorry everyone. Mere minutes after posting this, I decided to go on with what I could, saving this issue for later. I found a similar problem occurring with fstream. With this new information available, a Google search brought up this topic, and ultimately the solution.

I had defined my own min and max macros in my completely unrelated vector math files. The solution was to remove my macros and put std:: in front of the min and max calls.

Dwight