How do you std :: vector in Xcode + C ++?

For various reasons (and I assure you that they are valid, so there is no "use Cocoa"), I have to work with Xcode, C ++, OpenGL, OpenCL (with a little GLUT on the side) to rebuild several graphical demos on a Mac (from XP + Visual Studio 2005). The project was created 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. This file contains the following relevant lines of code:

#include <vector>
using std::vector;

and in the private section of the class:

vector<int> shaderHandles;

and when adding shader descriptors:

shaderHandles.push_back(shaderHandle);

and finally, when using pressed shader descriptors:

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

​​ ++. ( , _GLIBCXX_DEBUG), 4 :

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

, , stl_bvector.h vector.tcc, :

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

Google . Windows. , :

#include <list>
using std::list;

list<int> shaderHandles;

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

.

, :

#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;
}

.

.

, , Cocoa/Objective-C; . , , .

+3
2

. , , . , fstream. , Google , , .

min max . , std:: min max.

+3

Mac SDK, ? , ? , , .

0

Source: https://habr.com/ru/post/1720856/


All Articles