When I try to compile this:

#define NODES_MAX 100000
extern node_t _nodes[NODES_MAX];

It gives me this error:
------ Build started: Project: TheAlienEngine, Configuration: Debug Win32 ------
Compiling...
main.cpp
c:\documents and settings\tom\my documents\visual studio 2008\projects\thealienengine\thealienengine\ae_3d.h(12) : error C2148: total size of array must not exceed 0x7fffffff bytes
Generating Code...
Compiling...
core.cpp
c:\documents and settings\tom\my documents\visual studio 2008\projects\thealienengine\thealienengine\ae_3d.h(12) : error C2148: total size of array must not exceed 0x7fffffff bytes
Generating Code...
Compiling...
ae_3d.cpp
c:\documents and settings\tom\my documents\visual studio 2008\projects\thealienengine\thealienengine\ae_3d.h(12) : error C2148: total size of array must not exceed 0x7fffffff bytes
c:\documents and settings\tom\my documents\visual studio 2008\projects\thealienengine\thealienengine\ae_3d.cpp(7) : error C2148: total size of array must not exceed 0x7fffffff bytes
c:\documents and settings\tom\my documents\visual studio 2008\projects\thealienengine\thealienengine\ae_3d.cpp(7) : error C2148: total size of array must not exceed 0x7fffffff bytes
Generating Code...
Build log was saved at "file://c:\Documents and Settings\tom\My Documents\Visual Studio 2008\Projects\TheAlienEngine\TheAlienEngine\Debug\BuildLog.htm"
TheAlienEngine - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I can only get it to compile if I lower this limit to around 500.. this is not acceptable because I'm making a 3D engine and every object in my world will be a node_t...

Is there any way to fix this?

Recommended Answers

All 3 Replies

How about using C++ vectors?

I did that, and now it compiles, but now when I run it I get this:
Unhandled exception at 0x00419537 in TheAlienEngine.exe: 0xC00000FD: Stack overflow.

And it points to this:

std::vector<node_t> _nodes(NODES_MAX);

Here is the definition of node_t:

#ifndef NODE_T
#define NODE_T

#include "vec_t.h"
#include "model_t.h"

extern int nodes_counter;

struct node_t{
	int id;

	vec_t origin, position, rotation;

	model_t model;
	model_t collision_mask;

	void setPosition(vec_t pos)
	{
		position = pos;
	}

	void setRotation(vec_t rot)
	{
		position = rot;
	}
};

#endif

Why are you trying to allocate 100,000 of anything on the stack?
Do you really really really NEED that much storage as an initial allocation?
Maybe you should just use a vector, and add items as necessary?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.