returning a value from a constructor
    Steve Holle 
    sholle at link-comm.com
       
    Fri Feb 18 19:44:58 UTC 2005
    
    
  
We ran into an interesting problem today.  We tried to call the following 
rtems_libio functions from a c++ constructor :
       rtems_libio_check_fd( fd );
       iop = rtems_libio_iop( fd );
       rtems_libio_check_is_open(iop);
The first and third generated the following errors :
/tcb2/rlc/source/char_available.c:55: returning a value from a constructor
/tcb2/rlc/source/char_available.c:57: returning a value from a constructor
This baffled us for a time until we realized that these two functions were 
actually macros that contained returns for failure.  We solved the problem 
by calling a subroutine that called the two functions.  If the two 
functions were actually subroutines instead of macros the code would have 
compiled.
I know this would be a huge job and probably not worth the time but it 
would be helpful if it was easy to tell macros from subroutines.  One 
method I've seen in the past is that all macros are capitalized.
Just wanted to get this into the archive in case someone else runs into 
this problem.
Steve Holle
Link Communications, Inc.
1035 Cerise Rd.
Billings, MT  59101
sholle at link-comm.com  
    
    
More information about the users
mailing list