Hi, There are a couple of things I'm wondering about changing for the API:
1. Should we use underscores for struct names? E.g. _GeanyProject. I know GTK uses this, but I've read in C programming books that tag names with a leading underscore should not be used as the compiler uses them. Also it looks a bit ugly. But I don't know if there is a portability reason why GTK uses it.
2. Maybe we could add a 'geany' macro to pluginmacros.h that expands to (*geany_data) - this could be used instead of adding macros for app, prefs, etc. E.g. geany.app->configdir.
Regards, Nick
Hi,
On Thu, May 22, 2008 5:36 pm, Nick Treleaven wrote:
- Maybe we could add a 'geany' macro to pluginmacros.h that expands to
(*geany_data) - this could be used instead of adding macros for app, prefs, etc. E.g. geany.app->configdir.
I like this idea and I'm thinking this would make things much easier.
Frank
On Fri, 23 May 2008 08:01:15 -0000 (UTC) "Frank Lanitz" frank@frank.uvena.de wrote:
Hi,
On Thu, May 22, 2008 5:36 pm, Nick Treleaven wrote:
- Maybe we could add a 'geany' macro to pluginmacros.h that
expands to (*geany_data) - this could be used instead of adding macros for app, prefs, etc. E.g. geany.app->configdir.
I like this idea and I'm thinking this would make things much easier.
I think it would be neater, and maybe prevent some confusing error messages for name conflicts with macros. As I mentioned in another thread, we could deprecate all the existing variable macros.
One thing if we add it, do people prefer to write geany.app->configdir or geany->app->configdir?
Regards, Nick
On Fri, 23 May 2008 12:53:51 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Fri, 23 May 2008 08:01:15 -0000 (UTC) "Frank Lanitz" frank@frank.uvena.de wrote:
Hi,
On Thu, May 22, 2008 5:36 pm, Nick Treleaven wrote:
- Maybe we could add a 'geany' macro to pluginmacros.h that
expands to (*geany_data) - this could be used instead of adding macros for app, prefs, etc. E.g. geany.app->configdir.
I like this idea and I'm thinking this would make things much easier.
I think it would be neater, and maybe prevent some confusing error messages for name conflicts with macros. As I mentioned in another thread, we could deprecate all the existing variable macros.
One thing if we add it, do people prefer to write geany.app->configdir or geany->app->configdir?
No idea what people prefer, but I personally find geany->app->configdir better just because it's more consistent in itself, not mixing direct and reference access. But probably just a matter of taste.
Regards, Enrico
On Thu, 22 May 2008 18:36:11 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
Hi, There are a couple of things I'm wondering about changing for the API:
- Should we use underscores for struct names? E.g. _GeanyProject. I
know GTK uses this, but I've read in C programming books that tag names with a leading underscore should not be used as the compiler uses them. Also it looks a bit ugly. But I don't know if there is a portability reason why GTK uses it.
I started using the underscores because I thought this is common practise (at least I read a lot of code where underscores are used) and at some point there were problems if structs and types had the same name, so the easiest solution was to prefix the struct name with an underscore. Alternatively, we could use a suffix like _s instead. But this is a little more ugly ;-). But I don't think using different names for structs and types isn't that bad. It helps differencing the various symbols.
Regards, Enrico
On Sun, 25 May 2008 22:20:01 +0200 Enrico Tröger enrico.troeger@uvena.de wrote:
On Thu, 22 May 2008 18:36:11 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
...
- Should we use underscores for struct names? E.g. _GeanyProject. I
know GTK uses this, but I've read in C programming books that tag names with a leading underscore should not be used as the compiler uses them. Also it looks a bit ugly. But I don't know if there is a portability reason why GTK uses it.
I started using the underscores because I thought this is common practise (at least I read a lot of code where underscores are used) and at some point there were problems if structs and types had the same name, so the easiest solution was to prefix the struct name with
Do you remember what problems there were?
an underscore. Alternatively, we could use a suffix like _s instead. But this is a little more ugly ;-). But I don't think using different names for structs and types isn't that bad. It helps differencing the various symbols.
For the plugin API, in plugindata.h, we often need to use the struct name, so probably it would be best if we decided on the same convention. I don't mind using the _Name syntax if using the same name as the typedef causes problems.
Regards, Nick
On Mon, 26 May 2008 13:03:21 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
On Sun, 25 May 2008 22:20:01 +0200 Enrico Tröger enrico.troeger@uvena.de wrote:
...
I started using the underscores because I thought this is common practise (at least I read a lot of code where underscores are used) and at some point there were problems if structs and types had the same name, so the easiest solution was to prefix the struct name with
Do you remember what problems there were?
Just to add info:
Although I haven't yet found a link to the relevant part of the ISO C90 standard, I've read elsewhere that struct names and typedef names have separate namespaces.
http://blogs.msdn.com/oldnewthing/archive/2008/03/26/8336829.aspx
So for new code (such as our API) it ought to be fine to use the same name for each. Also I'm pretty sure I'd done this a few times already when we got the portability patch and that didn't mention that it was an issue. I know that C99 adoption is not good, but C90 should be fine.
Regards, Nick
On Tue, 27 May 2008 15:34:02 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Mon, 26 May 2008 13:03:21 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
On Sun, 25 May 2008 22:20:01 +0200 Enrico Tröger enrico.troeger@uvena.de wrote:
...
I started using the underscores because I thought this is common practise (at least I read a lot of code where underscores are used) and at some point there were problems if structs and types had the same name, so the easiest solution was to prefix the struct name with
Do you remember what problems there were?
Just to add info:
Although I haven't yet found a link to the relevant part of the ISO C90 standard, I've read elsewhere that struct names and typedef names have separate namespaces.
http://blogs.msdn.com/oldnewthing/archive/2008/03/26/8336829.aspx
So for new code (such as our API) it ought to be fine to use the same name for each. Also I'm pretty sure I'd done this a few times already
Ok, so let's use the same names for structs and typedefs.
Regards, Enrico
On Wed, 28 May 2008 17:46:36 +0200, Enrico Tröger enrico.troeger@uvena.de wrote:
On Tue, 27 May 2008 15:34:02 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Mon, 26 May 2008 13:03:21 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
On Sun, 25 May 2008 22:20:01 +0200 Enrico Tröger enrico.troeger@uvena.de wrote:
...
I started using the underscores because I thought this is common practise (at least I read a lot of code where underscores are used) and at some point there were problems if structs and types had the same name, so the easiest solution was to prefix the struct name with
Do you remember what problems there were?
Just to add info:
Although I haven't yet found a link to the relevant part of the ISO C90 standard, I've read elsewhere that struct names and typedef names have separate namespaces.
http://blogs.msdn.com/oldnewthing/archive/2008/03/26/8336829.aspx
So for new code (such as our API) it ought to be fine to use the same name for each. Also I'm pretty sure I'd done this a few times already
Ok, so let's use the same names for structs and typedefs.
Done (except I forgot one).
Regards, Enrico
On Mon, 26 May 2008 13:03:21 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Sun, 25 May 2008 22:20:01 +0200 Enrico Tröger enrico.troeger@uvena.de wrote:
On Thu, 22 May 2008 18:36:11 +0100, Nick Treleaven nick.treleaven@btinternet.com wrote:
...
- Should we use underscores for struct names? E.g.
_GeanyProject. I know GTK uses this, but I've read in C programming books that tag names with a leading underscore should not be used as the compiler uses them. Also it looks a bit ugly. But I don't know if there is a portability reason why GTK uses it.
I started using the underscores because I thought this is common practise (at least I read a lot of code where underscores are used) and at some point there were problems if structs and types had the same name, so the easiest solution was to prefix the struct name with
Do you remember what problems there were?
Unfortunately, not. Maybe I did something else wrong and it wasn't really related to the struct names (weren't the first time...;-)).
Regards, Enrico