4 ms·
This is absolutely beautiful. I didn't know you could get an address of a label in C or to do a goto to an address from variable instead of a literal label. Is
by klibertp 12y ago
This is absolutely beautiful. I didn't know you could get an address of a label in C or to do a goto to an address from variable instead of a literal label. Is this new in C, or was it always there?
- dietrichepp 12y agoIt's a GCC extension. https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
- techdragon 12y agoIs there an equivalent for Clang/LLVM?
- cjcole 12y agoYes. http://blog.llvm.org/2010/01/address-of-label-and-indirect-branches.html http://blog.llvm.org/2010/01/address-of-label-and-indirect-b... A venerable interpreter implementation trick.
- codehero 12y agoUnfortunately it won't port to IAR, which is a shame. I don't understand why pointers to labels never made it to the C spec; it's one of the (equivaling) features that actually makes assembler look elegant.