Page 1 of 1

What is Eclipse/GNU doing?

Posted: Tue Mar 03, 2020 1:20 pm
by SeeCwriter
Given the code snippets below, why doesn't the compiler (v2.9.2) throw an error and why doesn't the program crash in function Init()?

Code: Select all

////////// Header…
class c_interval            // interval timer based on TimeTick
  {
  public:
  volatile DWORD start_time, timeout, interval;
  explicit c_interval( DWORD msec = 1000 ); // interval in msec.
  void  Reset(DWORD msec=0);  
  bool  Cycle(DWORD msec=0); 	
  bool  Expired();            
  DWORD ElapsedSec();
  DWORD ElapsedMsec();
  DWORD RemainingSec();
  void  ForceExpiration();	
  };

struct s_amp_info
  {
  int   connected;
  c_interval cooldown; 
…


////////// Init()…
  s_amp_info *pamp = amp_info+amp;
  pamp->cooldown = 0;         // What does this do?! 
  pamp->cooldown.Reset(60000);  // Works.
  

Re: What is Eclipse/GNU doing?

Posted: Wed Mar 04, 2020 11:56 am
by jandarm
SeeCwriter,

where amp and amp_info are defined/declared? We aren't telepaths.

In the line

Code: Select all

pamp->cooldown = 0;         // What does this do?!
I guess default assignment operator is called. It's hard to say what is going on without full listings.