Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Simple example...

By: atomen on May 5th, 2012  |  syntax: C++  |  size: 0.59 KB  |  views: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Include files
  2. #include <vector>
  3.  
  4. struct Type
  5. {
  6.         int size;
  7.         bool pointerOrReference;
  8. }
  9.  
  10. int main(int argc, char * argv[])
  11. {
  12.         // The vector for all arguments
  13.         std::vector<Type> arguments;
  14.  
  15.         // Fill it up with miscellanous arguments
  16.         // ....
  17.         // ....
  18.  
  19.         // Then if I want to calculate the amount
  20.         // I want to 'push' the stack, would this
  21.         // be enough, or does it grow deeper than this?
  22.  
  23.         int sizeToPush = 0;
  24.  
  25.         for(int i = 0; i < arguments.size(); i++)
  26.                 sizeToPush += arguments[i].size;
  27.  
  28.         // And perhaps align the size here... (to a power of 2)
  29.         sizeToPush += (sizeToPush % 2);
  30. }