Starting with GeoCalc version 6.6, changes have been made in the way wchar_t strings are handled. These changes allow users to compile and use the GeoCalc API regardless of the settings of the "Use Wchar_t as a native type" compiler setting.
Introduction of BmgChar
All string variables now are of type BmgChar * instead of wchar_t *. Using BmgChar * in place of wchar_t * allows GeoCalc to properly handle strings regardless of the wchar_t setting on the compiler. In order to take full advantage of this, always use BmgChar * instead of wchar_t * when passing strings into any GeoCalc method. In addition, any method that returns a string will now return a BmgChar *.
The BMG_T Macro
In order to easily create new strings, the BMG_T macro has been introduced. Previously, to create a wchar_t * string, one would do the following:
wchar_t * theString = L"This is my String";
Now, the BMG_T macro is used instead of the L macro:
BmgChar * theString = BMG_T("This is my String");
Passing strings into GeoCalc methods would also work the same way. Previously:
DataSource *ds = new DataSource();
ds->LoadFile(L"C://bmg//GeoCalcPBW//data//geodata.xml");
Now, using BMG_T:
DataSource *ds = new DataSource();
ds->LoadFile(BMG_T("C://bmg//GeoCalcPBW//data//geodata.xml"));
Continuing to use the L Macro
It is possible to continue to use the L macro, and pass wchar_t strings around. It is possible to pass a wchar_t string into a BmgChar as long as the wchar_t compiler setting is set to "No (/Zc:wchar_t-)". If it is set to Yes, a compilation error will occur. Any time a wchar_t string is explicitly used in a GeoCalc object, the flexibility that was gained with the addition of BmgChar is lost.
For example, this LoadFile call will work ONLY with compiler flag (/Zc:wchar_t-) :
DataSource *ds = new DataSource();
ds->LoadFile(L"C://bmg//GeoCalcPBW//data//geodata.xml");
Comments
0 comments
Please sign in to leave a comment.