Injected code weirdness....VC 7
-
I just had a look at the code injected by the compiler when using the __event, __hook and __raise keywords on native C++ code. The sample in the help-files which come with VC 7.0 define a void-event like so; __event void MyEvent( int value ); and __hook a reciever to it and subsequently __raise it. Fine. So I changed it to this; __event int MyEvent( int value ); and looked at the generated code for the __raise, ( now returning an int ), which is like so;
inline void CSource::MyEvent(int i1) { __EventingCS.Lock(); __eventNode_CSource_MyEvent* node = __eventHandlerList_CSource_MyEvent; int hr = (int) 0; for (; node != 0; node = node->next) { hr = node->__invoke(i1); if ( hr!=0 ) { return hr; //< BAD STUFF HAPPENS HERE } } __EventingCS.Unlock(); return hr; }
( that comment is mine, not MS' :rolleyes: ), Is it just me or is this code broken ? The only way this code is not broken is if there is some secret exception handling semantics going on which I don't know about. If that's the case I stand corrected. However, if it is not, then that piece of code will die somewhere bad due to a deadlock. Anyone ? cheers -=jarl=- ---------------------------- jarl ostensen Lead Technology Programmer Bullfrog/Electronic Arts Inc.