# Atmel Studio: redefine weak function

I want to write my own implementation of SERCOM3_Handler. I put its definition in my main.c, try to compile it and get "multiple definition of SERCOM3_Handler" error. Why is this happening? The prototype of this function in the library headers is with the weak attribute.

• It seems that someone else has already defined that function without the weak attribute. Doesn't the linker tell where that conflicting definition is? – Wouter van Ooijen Nov 11 '15 at 13:05
• What uC are you using? SERCOM3_handler doesnt sound familiar to me. Are you sure that is the appropriate name for the ISR? What function of the uC are you trying to use? USART? – cventu Nov 11 '15 at 13:30
• are you sure you haven't put the definition of the function in a header file somewhere (as opposed to a declaration)? An alternative possibility is that you are #including "main.c" somewhere? Finally as @Wouter hints at the SERCOM3_Handler is already defined somewhere else - perhaps in a library? Actually just read - "the prototype has weak attribute" - try changing your declaration in main.c to be 'strong' – Icy Nov 11 '15 at 14:39
• I am using SAM D20 uC. In startup_samd20.c library file there is following line: void SERCOM3_Handler ( void ) attribute ((weak, alias("Dummy_Handler"))); – c_spk Nov 13 '15 at 5:21
• In agreement with what others have said, I've had this happen when FreeRTOS defined a handler that I didn't think it was using. Just grep (or some other recursive in-file search tool) your project folder: grep -rin SERCOM3_Handler – ahogen Jan 27 '18 at 6:23