Re:Obvious Things C Should Do
by TheNewAndy on Sunday January 12, 2025 @12:35AM
(#42671545)
Personally, I'm happy to just let a Sufficiently Advanced Compiler do link time optimizations to deal with that level of optimization and either take the hit, or make more things public while that compiler doesn't exist.
Let the header files be written for people to read first, and only if there is actually a big performance issue, and the problem is the interface do you need to revisit it (and I'm not just saying this - I will frequently and happily go back and modify interfaces to allow for less data movement etc, but most of the time it really isn't important).
I think you are probably right to disagree with me though - I think I should have said that it is more of a limitation on how object files work, rather than how machines work. Object files aren't the only way things can work.
A compiler can still have access to the internal layout in C via link-time optimization.
Re:Obvious Things C Should Do
by johannes1234321 on Sunday January 12, 2025 @10:23AM
(#42674192)
Linker is something different from Compiler (even if often called via same Frontend)
In a header file, the information for the compiler and the user are the exact same which means you can't reduce your public interface without straight up hiding more of yourself.