On 2016-01-06 12:23 PM, Thomas Martitz wrote:
Am 06.01.2016 um 21:12 schrieb Jiří Techet:
It's indeed at least interesting to consider, because at least for .h headers there really is some mixed stuff all over the place -- even, simply look in Scintilla's source tree.
+1 for having the headers parsed/lexed by the C++ parser (with sources it may be a bit dangerous and typically the sources have the right C++ extension).
Not replying to Jiří specifically.
-1. .h is legitimately a C, it's just that many people get it wrong. And I don't want C++ keywords highlighted in C headers while they are not highlighted it C source files. This is just confusing.
Why is .h any more C than C++ or Obj-C? Because it came first? I agree it's stupid that in the later part of last millennium, they decided on the convention to use .h for C++ and Obj-C (and others?) headers since it was already a convention in C, but it did become a convention in C++ and now it's widely used, for example [0][1][2][3] among many, many others.
What's more, it's especially useful to see C++ keywords highlighted in .h header files, since they can be included in C++ as well as C[4][5][6] unless their author wants to make them less useful by using said keywords in the header. I think the most common case would be someone doing it inadvertently (as happened in Geany), which is where having them highlighted differently gives a visual queue that something is wrong[7].
Cheers, Matthew Brush
[0]: https://git.gnome.org/browse/gtkmm/tree/gtk/gtkmm [1]: https://github.com/qtproject/qtbase/tree/dev/src/corelib/global [2]: https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/files.html [3]: http://sourceforge.net/p/scintilla/code/ci/default/tree/src/ [4]: https://git.gnome.org/browse/gtk+/tree/gtk/gtkwidget.h#n38 [5]: https://github.com/spurious/SDL-mirror/blob/master/include/SDL.h#L61 [6]: http://sourceware.org/git/?p=glibc.git;a=blob;f=include/stdlib.h;h=352339e85... [7]: Or if the author is being evil on purpose, it gives them the smug satisfaction that they're making life hard for C++ programmers :)