Skip to content

[feature request] add reference to clang as an extension #116862

Open
@olemayu

Description

@olemayu

I'd like to propose adding reference to C as an clang extension. The same one C++ has.

A reference, like a pointer, stores the address of an object that is located elsewhere in memory. Unlike a pointer, a reference after it's initialized can't be made to refer to a different object or set to null. There are two kinds of references: lvalue references, which refer to a named variable and rvalue references, which refer to a temporary object. The & operator signifies an lvalue reference and the && operator signifies either an rvalue reference, or a universal reference (either rvalue or lvalue) depending on the context.
https://learn.microsoft.com/en-us/cpp/cpp/references-cpp

int main() {
   int i; // Declare the object.
   int& ref = i; // Declare and initialize the reference.

   ref = 5;

   printf("%i\n", i); // "5"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    cclangClang issues not falling into any other categoryenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions