From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from spam02.hesby.net (spam01.hesby.net [81.29.32.152]) by sourceware.org (Postfix) with ESMTP id 10DF83857C71 for ; Sun, 11 Apr 2021 12:21:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 10DF83857C71 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hesbynett.no Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=david.brown@hesbynett.no Received: from [192.168.4.227] (247.92-221-34.customer.lyse.net [92.221.34.247]) by spam02.hesby.net (Halon) with ESMTPSA id 75c33020-9ac0-11eb-9b5d-506b8dfa0e58; Sun, 11 Apr 2021 14:21:38 +0200 (CEST) Subject: Re: static class member as interrupt handler works, but not if class is templated To: Klaus , Jonathan Wakely Cc: gcc-help , avr-gcc-list@nongnu.org References: <5f39cb4e-a445-bf19-ae90-b76c934aa930@gmx.de> <669cf66d-4e27-7b25-e1bd-d647d570645e@gmx.de> From: David Brown Message-ID: Date: Sun, 11 Apr 2021 14:21:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <669cf66d-4e27-7b25-e1bd-d647d570645e@gmx.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3031.8 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Apr 2021 12:21:44 -0000 On 10/04/2021 22:11, Klaus via Gcc-help wrote: > Hi, > > > > Am 10.04.21 um 17:26 schrieb Jonathan Wakely: > >> >>     Dummy<1> d1; >> >> >> This doesn't cause the instantiation of the member function. >> >> Have you tried an explicit instantiation? >> >> template class Dummy<1>; > > Did not change anything. > > If I use my original code, I get the instantiation of the function: > > 0000007e ::Handler()>: >   7e:    18 95           reti > > But it is simply not named as "__vector_10" which is the problem. The > member function is instantiated but still with wrong name even with my > or your code. > > Klaus > > To my knowledge, there isn't a better way than to make specific dedicated stand-alone functions: static void Handler_1() __asm__("__vector_10") __attribute__((__signal__, __used__, __externally_visibile__)) { Dummy<1>::Handler(); } For device drivers like that, you have a specific number of instantiations that match the number of peripherals on the particular microcontroller. And they each have different vectors. There really isn't any other better way, to my knowledge. (You can use a bit of pre-processing macros and conditional compilation to automate it a bit, generating as many of these functions as there are UARTs or whatever defined in the device header files for the microcontroller.)