Problems Mixing C and C++

Are there any know problems in mixing C and C++ with a GNU compiler ? I am asking this because we have a strange behavior with interrupts Thanks Noah

Hi Noah Which version of GCC are you using? Only on some of the early V3 series GCC builds the code generated for interrupt handler exiting didn’t use the correct method to restore the registers off the stack… Also from memory I think there may be a compiler / linker switch combo that needs to be used to ensure the correct interoperation of C and C++ code… as I think the stack framing is different… BBFN Dave

Hello Dave we use GCC 2.9. But the problem is not C++ related. I transformed the code into normal C code and the same problem occurred again I am debugging the code since day, but I haven’t gotten a glue what the cause of my problem is. The problem is somehow related to the interrupt handler. I have a thread which is waiting for data transmission to be completed over the serial interface. But occasionally , this thread has to wait forever, because somebody had switched of the interrupt (SER 2 TX level = 0x0C). I checked the variable “NAIRQMask” which indicates which interrupts had been switched on/off via the functions NAEnableIsr()/NADisableIsr(). According to this variable, the interrupt is switched on. But if I read the IER register (0xffb00030), while no other interrupt is pending, the interrupt is deactivated. Do you have a clue what the cause if this problem could be ? Thanks Noah

Hi Noah Sounds like something might be writing the IER register directly so getting the NAIRQMask out of sync or the NAEnableIsr()/NADisableIsr() functions themselves are not interrupt safe and the IER gets incorrectly updated because of an interrupt firing part way through their operation. Unfortunately I don’t use an operating system with the Net+50 so I’m probably not the best person to help you with this problem… Regards Dave

Hi Dave, thanks for you advice (and sorry that I did not reply earlier). The problem was caused (as you assumed) by the function NAEnableIsr()/NADisableIsr(). These functions are not reentrant because they access the global variable NAIRQMask . After disabling all Interrupts within these function solved the problem. Thanks Noah