4 ms·
That's a very weird comment, your spreading your knowledge and not really addresse what could have been changed in the article. If I follow your comment, you m
by kreco 10mo ago
That's a very weird comment, your spreading your knowledge and not really addresse what could have been changed in the article.
If I follow your comment, you mean that he could have use a non-static global variable instead and avoid mentioning "static" keyword afterward?
- deleted 10mo ago[deleted]
- unwind 10mo agoOh! Thanks, I was not being as concrete as I imagined. Sorry. Yes, the `static` can simply be dropped, it does no additional work for a single-file snippet like this. I tried diving into Compiler Explorer to examine this, and it actually produces slightly different code for the with/without `static` cases, but it was confusing to deeply understand quickly enough to use the output here. Sorry.
- mananaysiempre 10mo agoI see exactly the same assembly from x86-64 GCC 15.2 with -O2 the first example in the article both as is and without `static`, which makes sense. The two do differ if you add -fPIC, as though you’re compiling a dynamic library, and do not add -fvisibility=hidden at the same time, but that’s because Linux dynamic linking is badly designed.
- Chabsff 10mo agoTU-level concepts (mostly) dissolve during the linking stage. You need to compile with -c to generate an object file in order to see the distinction. Also, the difference manifests in the symbols table, not the assembly.
- mananaysiempre 10mo agoTo clarify, I was talking about Compiler Explorer-cleaned disassembly, same as the comment I was replying to.