On Thu, 13 Aug 2009 10:47:14 +0000, ctabin@users.sourceforge.net wrote:
Hi,
-extern GeanyPlugin* geany_plugin; -extern GeanyData* geany_data; -extern GeanyFunctions* geany_functions; +GeanyPlugin* geany_plugin; +GeanyData* geany_data; +GeanyFunctions* geany_functions;
sorry, I don't see the rational behind this. Even more, I think everything in PluginEntry.h is not necessary. You should declare the above listed symbols not in the header but instead only in those source files which actually need them. Same goes for the header includes.
It's not that the code is wrong but IMHO it's not the best way to handle includes and global variables.
Modified: trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c
--- trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c 2009-08-12 11:18:39 UTC (rev 894) +++ trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c 2009-08-13 10:47:14 UTC (rev 895) @@ -204,7 +204,7 @@
int putNewLine() {
- putCharInBuffer('\n');
- putCharInBuffer('\r\n'); int spaces = currentDepth*options->indentLength; int i; for(i=0 ; i<spaces ; ++i)
Not completely sure when this code is used and so I might be wrong. But if you want to insert line breaks, you can use the Geany preference 'file_prefs.default_eol_character' to insert these line break characters the user chose in his personal settings. I personally don't like to get any CRLF's auto-inserted in my files as I use LF exclusively.
Regards, Enrico
Hi Enrico,
Thansk for your advices. As I never developped very much in C with header files I don't know what's the best... I just see in another plugin that it was done like that and thought that it was the right way. However I don't understand why the 'extern' before my gean_* variables didn't work. I just saw an error into the debug messages of Geany. Maybe you can explain me that ? For the line returns, I put it it the struct configuration, so it will be configurable when I create the Preferences panel :-)
Regards, Cedric
2009/8/13 Enrico Tröger enrico.troeger@uvena.de
On Thu, 13 Aug 2009 10:47:14 +0000, ctabin@users.sourceforge.net wrote:
Hi,
-extern GeanyPlugin* geany_plugin; -extern GeanyData* geany_data; -extern GeanyFunctions* geany_functions; +GeanyPlugin* geany_plugin; +GeanyData* geany_data; +GeanyFunctions* geany_functions;
sorry, I don't see the rational behind this. Even more, I think everything in PluginEntry.h is not necessary. You should declare the above listed symbols not in the header but instead only in those source files which actually need them. Same goes for the header includes.
It's not that the code is wrong but IMHO it's not the best way to handle includes and global variables.
Modified: trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c
--- trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c 2009-08-12 11:18:39 UTC (rev 894) +++ trunk/geany-plugins/pretty-printer/src/PrettyPrinter.c 2009-08-13 10:47:14 UTC (rev 895) @@ -204,7 +204,7 @@
int putNewLine() {
putCharInBuffer('\n');
putCharInBuffer('\r\n'); int spaces = currentDepth*options->indentLength; int i; for(i=0 ; i<spaces ; ++i)
Not completely sure when this code is used and so I might be wrong. But if you want to insert line breaks, you can use the Geany preference 'file_prefs.default_eol_character' to insert these line break characters the user chose in his personal settings. I personally don't like to get any CRLF's auto-inserted in my files as I use LF exclusively.
Regards, Enrico
-- Get my GPG key from http://www.uvena.de/pub.asc
Geany-devel mailing list Geany-devel@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
On Fri, 14 Aug 2009 12:24:41 +0200 Cédric Tabin tabin.cedric@gmail.com wrote:
Thansk for your advices. As I never developped very much in C with header files I don't know what's the best... I just see in another plugin that it was done like that and thought that it was the right way. However I don't understand why the 'extern' before my gean_* variables didn't work. I just saw an error into the debug messages of Geany. Maybe you can explain me that ?
I haven't looked at your sources. But you should use extern for header declarations. You also need to declare *one* definition for each symbol, usually in the 'main' file.
Regards, Nick
On Fri, 14 Aug 2009 12:24:41 +0200, Cédric wrote:
Hi Enrico,
Thansk for your advices. As I never developped very much in C with header files I don't know what's the best... I just see in another plugin that it was done like that and thought that it was the right
It's not really wrong. Putting general header includes into header files just has the disadvantages that they are always included regardless of whether the .c files which include this header need the other includes in this header. This can slow down the compilation process, in this case it's probably not even noticeable but still. Another disadvantage is that you always include more than necessary, while having only the necessary header includes in the .c files is more cleaner and IMO easier to maintain. But it's probably a matter of taste.
For the line returns, I put it it the struct configuration, so it will be configurable when I create the Preferences panel :-)
But why? We already have such an option in Geany and you can easily use the value as I said in my pevious mail. Why do you want to add another option for that in your plugin. I think users would use the same value in your plugin as also in Geany itself. Furthermore while thinking about it, isn't it better at all just to use the same line ending characters as in the current file? Or could you just shortly describe what exactly happens when these newlines are inserted and why, maybe this helps to reduce my confusion. Thanks.
Regards, Enrico