So you think you know C? (2016)
161–170 of 344 posts
Re: So you think you know C? (2016)
#162Re: So you think you know C? (2016)
#163Can't even make the test. Which version of C? Which platform? Under DOS in the 90's, the answer to the first question would have been 3, it's not even proposed in the options.
Re: So you think you know C? (2016)
#164Re: So you think you know C? (2016)
#165My answer to a lot of these questions is "If you write code like this and check it in to our corporate repository, I will cut out your heart and make you eat it."
Re: So you think you know C? (2016)
#166Earlier quoted context omitted.
> In some of our code, we would test the size of various types and structures on startup This is one of the things that C++ has actually improved a lot recently: doing this with static_assert is much nicer in terms of catching problems early... And yes, it's great for long-term maintainability.
C has had standardized static assert since the C11 spec was released. See [1] for instance. [1]: https://stackoverflow.com/a/7287341
Re: So you think you know C? (2016)
#167UB nasal demons etc etc. But often we encounter UB in code that's already shipped. So it's good to have an intuition about what machine code was actually emitted, for example when deciding if a crash report is due to this particular UB, or not.
Re: So you think you know C? (2016)
#168I failed on one, number 4. I bravely assumed 16 bit integers cannot exist. Can anyone name a concrete platform/compiler where int is/was 16 bit. Or is this just a theoretical option left open by the spec?
Re: So you think you know C? (2016)
#169Earlier quoted context omitted.
Compile it, look at the assembly. You can know. The answer will vary from place to place, but it isn't non-existent.
With what compiler? Targeting what architecture? The question is underspecified. "I can't know" is correct.
Ans: A compiler.
Re: So you think you know C? (2016)
#170What are the best strategies to cope with the undefined areas in C?