944,181 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3044
  • C++ RSS
Oct 26th, 2009
0

C++ Array Size Limit?

Expand Post »
When I try to compile this:

C++ Syntax (Toggle Plain Text)
  1. #define NODES_MAX 100000
  2. 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?
Similar Threads
Reputation Points: 9
Solved Threads: 5
Posting Pro
tomtetlaw is offline Offline
591 posts
since Sep 2008
Oct 26th, 2009
0
Re: C++ Array Size Limit?
How about using C++ vectors?
Reputation Points: 11
Solved Threads: 18
Junior Poster
sureronald is offline Offline
139 posts
since May 2008
Oct 26th, 2009
0
Re: C++ Array Size Limit?
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:

c++ Syntax (Toggle Plain Text)
  1. std::vector<node_t> _nodes(NODES_MAX);

Here is the definition of node_t:

c++ Syntax (Toggle Plain Text)
  1. #ifndef NODE_T
  2. #define NODE_T
  3.  
  4. #include "vec_t.h"
  5. #include "model_t.h"
  6.  
  7. extern int nodes_counter;
  8.  
  9. struct node_t{
  10. int id;
  11.  
  12. vec_t origin, position, rotation;
  13.  
  14. model_t model;
  15. model_t collision_mask;
  16.  
  17. void setPosition(vec_t pos)
  18. {
  19. position = pos;
  20. }
  21.  
  22. void setRotation(vec_t rot)
  23. {
  24. position = rot;
  25. }
  26. };
  27.  
  28. #endif
Reputation Points: 9
Solved Threads: 5
Posting Pro
tomtetlaw is offline Offline
591 posts
since Sep 2008
Oct 26th, 2009
0
Re: C++ Array Size Limit?
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?
Reputation Points: 40
Solved Threads: 2
Light Poster
rdrast is offline Offline
30 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: checking a palindrom in linked list
Next Thread in C++ Forum Timeline: my code for the DynamicArray and matrix problem!!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC