C++ Array Size Limit?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 379
Reputation: tomtetlaw is an unknown quantity at this point 
Solved Threads: 4
tomtetlaw's Avatar
tomtetlaw tomtetlaw is offline Offline
Posting Whiz

C++ Array Size Limit?

 
0
  #1
34 Days Ago
When I try to compile this:

  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?
...
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 94
Reputation: sureronald is an unknown quantity at this point 
Solved Threads: 15
sureronald sureronald is offline Offline
Junior Poster in Training
 
0
  #2
34 Days Ago
How about using C++ vectors?
Catch me here!
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 379
Reputation: tomtetlaw is an unknown quantity at this point 
Solved Threads: 4
tomtetlaw's Avatar
tomtetlaw tomtetlaw is offline Offline
Posting Whiz
 
0
  #3
34 Days Ago
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:

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

Here is the definition of node_t:

  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
...
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 17
Reputation: rdrast is an unknown quantity at this point 
Solved Threads: 1
rdrast rdrast is offline Offline
Newbie Poster
 
0
  #4
33 Days Ago
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?
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC