C - Convert string to variable name

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

C - Convert string to variable name

跳至解决方案
2,094 次查看
andréluis
Contributor II

Hello, i'm using a MIMRXT100-EVK and i want know if it's possible to convert a string into a variable name using C. Or if i can compile some application in python or C++ to make this. 

Thanks for the help.

0 项奖励
回复
1 解答
2,075 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @andréluis,

This is not possible in programming languages like C or C++ Source 1, Source 2. As stated in the second link, C++ and specially C work by doing most of the computations during compile time rather than runtime. This way, the MCU executes a set of predefined (or precompiled) steps during runtime. Therefor, it cannot change it's variable names or recompile them in runtime, no. Source 1 has some code snippets that might prove to be work arounds, however.

Sorry for the inconvenience this may cause.

BR,
Edwin.

在原帖中查看解决方案

0 项奖励
回复
1 回复
2,076 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @andréluis,

This is not possible in programming languages like C or C++ Source 1, Source 2. As stated in the second link, C++ and specially C work by doing most of the computations during compile time rather than runtime. This way, the MCU executes a set of predefined (or precompiled) steps during runtime. Therefor, it cannot change it's variable names or recompile them in runtime, no. Source 1 has some code snippets that might prove to be work arounds, however.

Sorry for the inconvenience this may cause.

BR,
Edwin.

0 项奖励
回复