Is there an opposite operator for @encode?
For example, when you do this: @encode(int), you get "i". I’d like to be able to do this: @decode("i") myInt = 5;
Is this possible? Does an operator exist to handle this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No.
@encodetakes a type, and in C, it’s not possible to return a type. (Thetypeof()operator is a GNU extension but it doesn’t take a C string, so what you want is not possible.You have two options. One: redesign your code. If you need this, you probably have a design problem.
Two, use dynamic memory allocation and write your own function that takes a type string and allocates memory accordingly.