home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,723 of 33,346   
   ronnirubin@sprintmail.com to All   
   static problems   
   12 Dec 12 19:33:55   
   
   { Please limit your text to fit within 80 columns, preferably around 70,   
     so that readers don't have to scroll horizontally to read each line.   
     This article has been reformatted manually by the moderator. -mod }   
      
      
   I'm trying to automatically calculate the number of floating point   
   operations a program performs, to estimate timing on an embedded   
   processor.  Since I already had a declared working floating point,   
   so I could see whether float-32 would be adequate, I could already   
   automatically assign all my floating point variables with a typedef   
   What I tried was something like:   
      
   template  class INT {   
   FP val;   
   static unsigned long adds;   
   static unsigned long muls;   
   static unsigned long divs;   
   ....   
   public:   
   static void init()   
   {   
       adds = 0;   
       muls = 0;   
       divs = 0;   
   ...   
   }   
      
   INT (const INT a) : val(a) {}   
   ...   
   operator += INT(INT x)   
   {   
       adds++;   
       val += x.val;   
       return *this;   
   }   
   ...   
   friend INT operator+ (const INT a, const INTb)   
   { INT c = a; a += b; return c;}   
   ...   
   } ;   
      
   Unfortunately, the compiler I have, which claims to be C++/200X   
   complient, doesn't allow me to declare   
      
   unsigned long INT::adds;   
      
   Any ideas?   
      
   --   
   Arthur L. Rubin   
      
      
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca