News for hackers. Stuff that matters.
Re:The C++ Build Process Explained by pcwalton on Wednesday November 14, 2018 @08:18PM (#18456045)
Header files absolutely are a hassle to keep up to date. Besides, they're a terrible experience. You have to pay attention to include order! You have to write forward declarations! You have to write include guards, in 2018!

They're also bad as an overview. They may have been good in the 1980s, but nowadays a proper documentation generator gives you better formatting, search features, and cross-references. Inline documentation is particularly obnoxious in header files: I like seeing function-level documentation alongside interface and implementation, but if I put the documentation in both the .cpp and the .h file it's duplicated in two places and easily gets out of date.

Re:The C++ Build Process Explained by beached_whale on Wednesday November 14, 2018 @11:30PM (#18456869)
The order of headers mattering is very rare though and not indicitive of normal C++ code. It's rare, but not unheard of unfortunately as most C code is also available to C++.
Re:The C++ Build Process Explained by westmeal on Wednesday November 14, 2018 @09:52PM (#18456497)
Does #pragma once count as an include guard in your book?
Re:The C++ Build Process Explained by jchb on Wednesday November 14, 2018 @10:10PM (#18456578)
#pragma once is not in any C++ standard, although basically all modern compilers support it. The reason it is not in the standard is that its behaviour in the presence of symlinks may differ depending on the filesystem and compiler. Is it the unique combination of filename + content that should be included once or is it the file path? etc.
Re:The C++ Build Process Explained by josefx on Thursday November 15, 2018 @05:33AM (#18458254)
> The reason it is not in the standard is that its behaviour in the presence of symlinks may differ depending on the filesystem and compiler

I have the feeling that the difference matters to almost nobody and should be avoidable by the few people it actually affects. I had more issues with colliding include guards than I had with symlinks and I still end up replacing CLASSNAME_H with PROJECT_CLASSNAME_H in our own headers every now and then since the autogenerated guards are too naive.

Re:The C++ Build Process Explained by tjoff on Thursday November 15, 2018 @02:42AM (#18457577)
> You have to pay attention to include order! You have to write forward declarations! You have to write include guards, in 2018!

Include order is a valid complaint, the others truly are non issues.

I mean, we have other more pressing issues. Such as the fact that garbage collection is still a thing in 2018.

> ...but nowadays a proper documentation generator gives you better...

Examples of that?

> I like seeing function-level documentation alongside interface and implementation, but if I put the documentation in both the .cpp and the .h file it's duplicated in two places and easily gets out of date.

This is the only thing that I dislike about header files. And it is a constant reminder how bad IDEs are at handling this.

Re:The C++ Build Process Explained by omegote on Thursday November 15, 2018 @03:08AM (#18457668)
Doxygen can generate a list of all class members, including those from all ancestors. If you wanna do that checking header files you'll have to keep jumping between files going from parent to parent class.
Re:The C++ Build Process Explained by tjoff on Thursday November 15, 2018 @03:13AM (#18457689)
... doxygen, no. I'd rather take header files than doxygen.

I hope he meant something else since he said "nowadays". Doxygen is ok if you haven't setup your build environment. But for when you actually are in the code (and somewhat familiar with it) I very much prefer just reading the header files than switching to a browser.

Re:The C++ Build Process Explained by enriquto on Thursday November 15, 2018 @04:18AM (#18457953)
> Header files absolutely are a hassle to keep up to date.

This happens because there is some redundancy between the header file and the source. You can often arrange your code so that there is no redundancy (or almost zero).

Re:The C++ Build Process Explained by jcelerier on Thursday November 15, 2018 @05:50AM (#18458318)
> Header files absolutely are a hassle to keep up to date.

how so ? every IDE I've used automatically changes the header if you change the cpp and conversely