Skip to main content
GameDev.net gamedev.net
🔒 Locked

How do I create this vector? (canceled)

Started by MarauderX Aug 1, 2006 at 3:11 PM 3 replies 500+ views
Original Post
MarauderX
MarauderX
Sorry, but I was not very clear in my last post. I would like to ask my question again if you don't mind: How can I create a std::vector and put data in it of a type I created with 'typedef struct'? [Edited by - MarauderX on August 1, 2006 3:49:24 PM]
dave
dave
struct MyStruct{  ... Some data ...};std::vector< MyStruct > myVector;

Dave
MarauderX
MarauderX
If I do that I get the following error, wich I don't understand:

CCameras.cppC:\Program Files\Microsoft Visual Studio 8\VC\include\vector(694) : error C2719: '_Val': formal parameter with __declspec(align('16')) won't be aligned        D:\CodenameM\CCameras.h(16) : see reference to class template instantiation 'std::vector<_Ty>' being compiled        with        [            _Ty=STRUCT_CAMERA        ]


this is my code:

#include <d3dx9.h>#include <vector>struct STRUCT_CAMERA{    // some data} ;class CCameras{private:	std::vector< STRUCT_CAMERA > cams;	public:    CCameras();    ~CCameras();};


dave
dave
That compiles fine for me.
jpetrie
jpetrie
You have failed to provide adequate information. Post all of your code, don't omit things -- those may very be the things that are important.

In this case, I suspect that "// some data..." includes at least one object such as D3DXMATRIXA16, which is declared with the __declspec(align(16)) keyword. This causes the error, not the use of "typedef struct" (which I maintain you should avoid -- this is C++, where it is unneccessary and ugly). The alignment cannot be maintained, so the object cannot be stored.

Don't use structures requiring alignment, or write your own allocator.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.