On Sun, 16 Aug 2009 23:14:19 +0200, Colomban wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Enrico Tröger wrote:
On Sun, 16 Aug 2009 22:08:00 +0200, Colomban wrote:
Just for my self curiousity about including order: why does it is required? I'm a partisan of the "include all you need, but no more" style, meaning that if I use a symbol, I have to include what defines it. e.g. for sciwrappers.h, I would include glib.h as it uses GLib types and define or include something that defines PLAT_GTK. I don't see any
You want to define things in your code again just to not include a header file?
No, but include the header defining them rather than needing the user to do so.
So, this is what geany.h does and for plugins it's geanyplugin.h.
Single header includes are generally more easy and pretty common. E.g. GTK and GLib do require them since some time. In case of Geany, the overhead which raises by including a bit more than strictly necessary is really really small compared what overhead GTK brings in and so I really don't see any real reason. At least, IMO, the advantages for maintainers and plugin authors are much bigger.
I think I've been misunderstood quite a bit, sorry. No, I'm not against single-header policy, even if I think is cleaner to include only what I need when possible, but for a library (like GTK+), for sure I see the point of one single global header including all others. What I'm against, and what I don't understand, is "missing" includes in headers. I think it is a bit cleaner, easier and less error prone to have each header to be self-sufficient in regard of the including code, i.e. if sciwrappers.h needs geany.h, I think sciwrappers.h should include geany.h itself rather than needing to be included before by the including code. In other words, when I include a header, I care about functionalities it provides (declares), and I won't care about how it is implemented (then what it needs). For example, if I would use foo, I include foo.h, and I wouldn't have to care that the the public Foo structure have a member of the Bar type (defined in bar.h) that I don't use. Hum, I think I should have said "include all you need" without the "but no more" that was only here to say that I wouldn't include *directly* (no care about it is included by what I include) headers I don't need.
Ok, I got it now. Sorry. Still in Geany itself, first include geany.h, for any plugins just include geanyplugin.h and you are done. Yes, we could change the code so that headers are safer to be included more randomly but who does it? Regarding Geany's core code, basically, it is just geany.h which you should include at first. Other headers' order doesn't matter much.
In my first post in this thread I said the order of the includes is important, that is only partly true and with the new geanyplugin.h it isn't true anymore at all because you have only one include and so the order is not important, haha.
But assuming one doesn't use geanyplugin.h and instead includes various headers, the order is important in that way that you: - first include geany.h - then include other core Geany header as well as Scintilla and tagmanager headers if necessary - finally include pluginmacros.h and geanyfunctions.h
Again, now, just include geanyfunction.h and we don't need to discuss this further.
Btw, say big thanks to Nick who brought us this great header.
Regards, Enrico