News for hackers. Stuff that matters.
Re:How to find size of an array in C without sizeof by babuskov on Monday December 26, 2016 @04:15PM (#13259800)
> please encapsulate the logic in a macro.

Why?

When reading such code, it means I would have to go and lookup a macro definition. So, there's a clear drawback. What's the benefit that makes it worthwhile?

Re:How to find size of an array in C without sizeof by Tempest1981 on Monday December 26, 2016 @04:40PM (#13259901)
Faster to read, and keeps the reader's mind at a semantically higher level.
Re:How to find size of an array in C without sizeof by EpicEng on Tuesday December 27, 2016 @07:40PM (#13267555)
I disagree. If you've progressed beyond the absolute beginner phase you know exactly what that line is when you see it. You've only put in work to obfuscate your code a bit and (potentially) cause conflicts with other units whose author had the same idea.
Re:How to find size of an array in C without sizeof by babuskov on Monday December 26, 2016 @05:56PM (#13260223)
Provided that he knows about the macro. Otherwise it's slower and if you switch projects often it requires that you remember what's it about.

I guess it could be useful for teams working together on bigger codebases.

Re:How to find size of an array in C without sizeof by Namrog84 on Monday December 26, 2016 @06:42PM (#13260369)
1. An appropriate named macro shouldn't cause you to need to investigate it unnecessarily

2 most IDEs allow simple hover over and see macro definition without having to break much flow.

Re:How to find size of an array in C without sizeof by verdax_1 on Tuesday December 27, 2016 @02:53AM (#13261881)
I might go a step further and append "an appropriately implemented macro". Just because something has a good name doesn't mean it's not filled with crazy.

Otherwise I totally agree with your point.

Re:How to find size of an array in C without sizeof by jjnoakes on Monday December 26, 2016 @11:46PM (#13261321)
If the macro is named appropriately, you don't have to go look up anything. And even if you do, you do it once (per project perhaps). No big deal.

I mean, you don't go look up the definitions of every function that gets called, every time they are called, right?