Am 12.04.21 um 15:46 schrieb David Brown:
Certainly templates can be instantiated zero, once, or multiple times. And certainly some templates are intended only to be instantiated a single time. But it would surely be difficult to have a feature that only works when there is a single instantiation.
You don't have to be worry about. If it is instantiated zero times, nothing happens, if it instantiates once, it gets the new name, if it instantiates multiple times, it get multiple instances with the same name and fails during linking. Absolutely fine!
There is also the issue of linkage of the names here. A template instantiation has function/method names that are mangled with the template type, template parameters, parameter types, etc. These have a particular kind of linkage that lets the toolchain (compiler, assembler and linker) know that they can be defined in more than one unit, and at link time one of them (by unspecified choice) can be picked for the final binary. An assembly-defined specific name for an interrupt vector, on the other hand, is a C external linkage name that can only be defined once. I don't see that these two uses could easily be combined.
There should be anything combined. The templated instance simply should have the name from asm statement which has C linkage.
It seems natural to me that a feature which can only be relevant to a single instantiation of a template should be connected to an instantiation, not a definition. This is particularly true when the details of the attribute you want - the "vector" assembly name - are dependent on a non-type parameter for the template.
The opposite is meant! It is intended by using the asm statement that we have a single name, fully independent of parameters for the template. Klaus