title: Is there a way to limit data size at C++ compile time and produce a compile error?
body: <p>I have build a tool that enable students to compile and test their own C++ code on line (on a protected environment).</p>
  
  <p>I would like to check, at compile time, that the total amount of data size in a program does not exceed a certain size, and produce a compile error if it does.</p>
  
  <p>(immediate goal : limit c++ std::array size )</p>
  
  <p>I did not find information on the Web.</p>
  
  <p>My compile chain is :</p>
  
  <pre><code>g++ -Wall -Wextra -Waddress -std=c++11 -lm -fstack-protector -lm -o exename srcname
  </code></pre>
  
  <p>Thanks for help.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I give them a skeleton, and they have to complete where (here) is specified :</p>
  
  <p>"Complete the program (here) with the definition of 'produitTableau' that get an a 2 dimensional array of integer et an integer  and that apply  'calcul' function to each of its vallues and that returns the modified array." (in french...)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;array&gt;
  using namespace std;
  
  const int NB = 3;
  
  int calcul (int a, int b);
  array&lt;array&lt;int, NB&gt;,NB&gt; produitTableau(array&lt;array&lt;int, NB&gt;,NB&gt; t, int a);
  
  int main()
  {
      /* déclaration et initialisation  */
      array&lt;array&lt;int, NB&gt;,NB&gt; tab ;
      int x;
      cin &gt;&gt; x;
      for (int i=0;i&lt;NB;i++) {for(int j=0; j&lt;NB; j++) {cin &gt;&gt; tab[i][j];}}
  
      /* traitement et résultat  */
      tab = produitTableau(tab, x);
  
      /* résultat */
      for (int i=0; i &lt; NB; i++) {
        for (int j=0; j &lt; NB; j++) {
          cout &lt;&lt; tab[i][j] &lt;&lt; " ";
        }
      }
  
    return 0;
  }
  
  int calcul(int a, int b)
  {
     return a*b;
  }
  
  **(here)**
  </code></pre>
  
  <p>I expect them to write something like (I check the result with a test data set that is store in a text file and that is used as input data) :</p>
  
  <pre><code>array&lt;array&lt;int, NB&gt;,NB&gt; produitTableau(array&lt;array&lt;int, NB&gt;,NB&gt; t, int a)
  {
      for (int i=0; i &lt; NB; i++) {
        for (int j=0; j &lt; NB; j++) {
          t[i][j] = calcul(t[i][j] , a);
        }
      }
  
     return t;
  
  }
  </code></pre>
  
  <p><strong>* the array is passed by value *</strong></p>
  
  <p>So I would check that the total amount of data used is thess than a certain value, for example : 10.000 bytes.</p>
  
  <p>May be it could be the exe file...I don't know that.</p>