开发者

Way to find out allocation type of variables in function

开发者 https://www.devze.com 2023-03-12 12:02 出处:网络
I want to find out storage type of variables in a function block. How to check if compiler has elevated auto variable storage to register storage or if variables declared with register storage are hon

I want to find out storage type of variables in a function block. How to check if compiler has elevated auto variable storage to register storage or if variables declared with register storage are honored by compiler? I am assuming by seeing the assembly code of the obj file after optimization would开发者_开发知识库 give us an idea. Please list the switch that I need to use with gcc or cl.exe to get this information?


The -S switch in gcc is the one you are looking for.
See §3.2 Options Controlling the Kind of Output (GCC manual)


You can look at the generated assembly, but there's no way to programmatically determine this from within your program. Generally be aware that GCC ignores the register keyword except to issue errors if you try to take the address of a register-storage variable, and when used in common with GCC-specific extensions to force a variable into a particular register for use in conjunction with inline asm. No idea what MSVC does.

0

精彩评论

暂无评论...
验证码 换一张
取 消