What does int & mean

后端 未结 6 770
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 15:39

A C++ question,

I know

int* foo(void)

foo will return a pointer to int type

how about

int &foo(void)
         


        
6条回答
  •  我在风中等你
    2020-12-12 16:37

    From Alfred's comments

    This is what the document says, Texas instrument's TMS320C28x C/C++ compiler intrinsics, page 122, int&__byte(int, unsigned int), I guess it is different from PC – Alfred Zhong

    From the manual:

    int &__byte(int *array, unsigned int byte_index);

    MOVB array[byte_index].LSB, src

    The lowest adressable unit in C28x is 16 bits. Therefore, normally you cannot access 8-bit MOVB dst, array[byte_index]. LSB entities off a memory location. This intrinsic helps access an 8-bit quantity off a memory location, and can be invoked as follows:

    __byte(array,5) = 10;
    b = __byte(array,20);

    This just means that the function returns a reference to an integer that acts like an 8 bit quantity. Because the value is a reference modifying will modify the object at the destination (just like the MOVB) instruction, while assigning to b will copy (just like MOVB) to the destination.

提交回复
热议问题