Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

AutoVersioning Plugin

<< < (22/41) > >>

JGM:
Well finally, new version 0.9 compiled and ready to install, with corrections to the problems marked by users since version 0.8

Check the first post for the recent list of changes on page 1 of this topic or the links above in my signature.

Jeisson:
I beg your pardon if these questions are posted already. I am using wx in unicode, so when I try to convert a char[] static variable to unicode, I get errors:

--- Code: ---// This line in MainFrame.cpp
wxT(AutoVersion::YEAR)

// generate these errors:
MainFrame.cpp:344: error: `LAutoVersion' has not been declared
MainFrame.cpp:344: error: `YEAR' was not declared in this scope
MainFrame.cpp:344: warning: unused variable 'YEAR'

// And not used variables in version.h generate warnings:
.\version.h:9: warning: 'AutoVersion::YEAR' defined but not used
.\version.h:10: warning: 'AutoVersion::UBUNTU_VERSION_STYLE' defined but not used
//...

--- End code ---

Have somebody experienced that problems? I think, warnings could be avoided if the plugin generated a class instead of a namespace.

Thanks a lot in advance!

JGM:

--- Quote from: Jeisson on October 09, 2007, 10:26:19 pm ---I beg your pardon if these questions are posted already. I am using wx in unicode, so when I try to convert a char[] static variable to unicode, I get errors:

--- Code: ---// This line in MainFrame.cpp
wxT(AutoVersion::YEAR)

// generate these errors:
MainFrame.cpp:344: error: `LAutoVersion' has not been declared

--- End code ---

--- End quote ---

You don't have to beg anything, is fine, in fact, is a good question. Answering your question, well I tried to make the plug in general with variables using C/C++ standards, for convenience. :)

I personally use these custom functions using a wxwidgets compiled as unicode on linux and windows without any problems.


--- Code: ---//wxString to std::string
string ws2s(wxString as){
    return string(as.mb_str(wxConvISO8859_1));
}

//std::string to wxString
wxString s2ws(string s){
    return wxString((s).c_str(),wxConvISO8859_1);
}

//C string to wxString
wxString cs2ws(const char* s){
    return wxString(s,wxConvISO8859_1);
}

--- End code ---


--- Quote from: Jeisson on October 09, 2007, 10:26:19 pm ---
--- Code: ---MainFrame.cpp:344: error: `YEAR' was not declared in this scope
MainFrame.cpp:344: warning: unused variable 'YEAR'

// And not used variables in version.h generate warnings:
.\version.h:9: warning: 'AutoVersion::YEAR' defined but not used
.\version.h:10: warning: 'AutoVersion::UBUNTU_VERSION_STYLE' defined but not used
//...

--- End code ---

I think, warnings could be avoided if the plugin generated a class instead of a namespace.

--- End quote ---

Good Idea  :) I doesn't thought that. Well I will leave the namespace, for some good reasons recommended by killerbot,  and add a static class inside, named VersionInfo (or something shorter, I don't know). So it will be like this:

AutoVersion::VersionInfo::Major

or

using namesapce AutoVersion;
VersionInfo::Major

Those warnings where peacing me off too :P

But I don't know how to do it with the C header version, to stop the warnings from coming. May be with a struct, i don't remember if struct's could be initialized on C. Well create some struct interface, declare a variable of class struct and initialize the values there for the users to use.

I will like to know the opinions of the people using the plug in before changing the code. So my eyes and ears are open  :)

Jeisson:
Thanks JGM for your affable words. You are right, the conversion constructor for single byte strings to wxString works perfectly:


--- Code: ---wxString(AutoVersion::YEAR, wxConvISO8859_1)
--- End code ---

I found a simpler solution for avoiding warning messages. Instead of generating global variables into the namespace, you could generate consts. Moreover, this change prevents the user can change the values accidentally. The following could be an example:


--- Code: ---#ifndef VERSION_H
#define VERSION_H

namespace AutoVersion{

//Date Version Types
static const char DATE[] = "10";
static const char MONTH[] = "10";
static const char YEAR[] = "2007";
static const double UBUNTU_VERSION_STYLE = 7.10;

//Software Status
static const char STATUS[] = "Alpha";
static const char STATUS_SHORT[] = "a";

//Standard Version Type
static const long MAJOR = 0;
static const long MINOR = 1;
static const long BUILD = 1;
static const long REVISION = 53;

//Miscellaneous Version Types
static const long BUILDS_COUNT = 65;
#define RC_FILEVERSION 0,1,1,53
#define RC_FILEVERSION_STRING "0, 1, 1, 53\0"
static const char FULLVERSION_STRING[] = "0.1.1.53";

}
#endif //VERSION_h
--- End code ---

Simply, add the const reserved word in each declaration :D.
Thanks again for your amiability.

JGM:

--- Quote from: Jeisson on October 10, 2007, 07:19:05 pm ---I found a simpler solution for avoiding warning messages. Instead of generating global variables into the namespace, you could generate consts. Moreover, this change prevents the user can change the values accidentally.

--- End quote ---

Great I test it and warnings are gone. Well I have committed the changes to svn.
Thanks for your help  :D

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version