www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21934] New: importC: Support asm labels to specifying the

https://issues.dlang.org/show_bug.cgi?id=21934

          Issue ID: 21934
           Summary: importC: Support asm labels to specifying the
                    assembler name to use for a C symbol
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

6.47.4 Controlling Names Used in Assembler Code

You can specify the name to be used in the assembler code for a C function or
variable by writing the asm (or __asm__) keyword after the declarator. It is up
to you to make sure that the assembler names you choose do not conflict with
any other assembler symbols, or reference registers.
Assembler names for data:

This sample shows how to specify the assembler name for data:

int foo asm ("myfoo") = 2;

This specifies that the name to be used for the variable foo in the assembler
code should be ‘myfoo’ rather than the usual ‘_foo’.

On systems where an underscore is normally prepended to the name of a C
variable, this feature allows you to define names for the linker that do not
start with an underscore.

GCC does not support using this feature with a non-static local variable since
such variables do not have assembler names. If you are trying to put the
variable in a particular register, see Explicit Register Variables.
Assembler names for functions:

To specify the assembler name for functions, write a declaration for the
function before its definition and put asm there, like this:

int func (int x, int y) asm ("MYFUNC");

int func (int x, int y)
{
   /* … */

This specifies that the name to be used for the function func in the assembler
code should be MYFUNC.

--
May 20 2021