This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI C/C++ Compiler
According to the C2000 wiki:
Q: The prototype for __byte is &__byte(int *array, unsigned int byte_index). Is the "&" a typo?
If the return value is indeed a C++ style reference, why does the following result in a compiler error?
int test[4];
int &x = __byte(test, 0);
"../main.cpp", line 139: error #436: a reference of type "int &" (not const-qualified) cannot be initialized with a value of type "int"
RallyTronics said:If the return value is indeed a C++ style reference
When used anywhere other than the left side of an assignment, the __byte intrinsic just returns an int. Only when used on the left side of an assignment does it act like a C++ reference. Even in that case, you don't write a & when using it. Perhaps borrowing the & reference operator from C++ is not the best way to explain the __byte intrinsic. I apologize for the confusion.
Thanks and regards,
-George
Thanks, that's what I anticipated. The issue came up when trying to overload the [] operator for a byte array class:
int &operator[](int i)
{
return __byte(_store,i);
}