This question already has an answer here:
This question is similar to other posted about /bigobj issues, however, these did not directly address the compiler options in general. This specifically answer the general question of compiler options, and handles the separate issue of the specific compiler option as well, and even goes further to link other similar questions in order to be more easily found than the others.
I need to initialize a struct with over 16641 elements.
#include "stdafx.h"
#include <iostream>
struct ArtificialIdiocy{
double x, y, z;
double nx, ny, nz;
};
int _tmain(int argc, _TCHAR* argv[]){
ArtificialIdiocy objectArray[16641];
objectArray[0].x = 1.012709;
objectArray[0].y = 0.069911;
objectArray[0].z = 1.010933;
objectArray[0].nx = 0.165410;
objectArray[0].ny = 0.883572;
objectArray[0].nz = -0.438063;
objectArray[1].x = -1.000000;
objectArray[1].y = 0.014457;
objectArray[1].z = 1.000000;
objectArray[1].nx = 0.179296;
objectArray[1].ny = 0.883511;
objectArray[1].nz = -0.432661;
objectArray[2].x = 1.000693;
objectArray[2].y = 0.011744;
objectArray[2].z = -1.000509;
objectArray[2].nx = 0.172582;
objectArray[2].ny = 0.897122;
objectArray[2].nz = -0.406629;
// so on, and so on....
objectArray[16638].x = 0.969018;
objectArray[16638].y = 0.116736;
objectArray[16638].z = 0.967181;
objectArray[16638].nx = 0.437513;
objectArray[16638].ny = 0.782861;
objectArray[16638].nz = 0.442335;
objectArray[16639].x = 0.968575;
objectArray[16639].y = 0.105999;
objectArray[16639].z = 0.998326;
objectArray[16639].nx = 0.561235;
objectArray[16639].ny = 0.718528;
objectArray[16639].nz = 0.410718;
objectArray[16640].x = 0.999139;
objectArray[16640].y = 0.089730;
objectArray[16640].z = 0.997266;
objectArray[16640].nx = 0.608631;
objectArray[16640].ny = 0.688559;
objectArray[16640].nz = 0.394208;
But the MSVS2013 compiler tells me that my struct has to many sections and quits with an error stating:
Error 1 error C1128: number of sections exceeded object file format limit : compile with /bigobj
How do I edit/add the "/bigobj" compiler switch?
For MSVS Express 2013, open your projects "Property Pages", go to the "C/C++" tree item, and then go down to where you see the very last option, "Command Line". Click on this, and add any additional switches in the "Additional Options" text-box.
In this case, you would add "/bigobj", all lower-case letters.
See also:
Penalty of the MSVS compiler flag /bigobj
Build issue with MSVS 2010 and the C++ standard
How to compile with /bigobj within Dymola (Modelica)
Just found the following while linking this question to others:
http://msdn.microsoft.com/en-us/library/ms173499%28v=VS.100%29.aspx
http://msdn.microsoft.com/en-us/library/8578y171.aspx