[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
Re: [XaraXtreme-dev] compile failure with recent versions
- From: Vasil Dimov <vd@xxxxxxxxxxx>
- Date: Thu, 20 Apr 2006 08:41:57 +0300
- Subject: Re: [XaraXtreme-dev] compile failure with recent versions
On Tue, Apr 18, 2006 at 02:12:02PM +0100, Luke Hart wrote:
> Vasil Dimov wrote:
>
> >Hi all,
> >
> >I am trying to port the latest version of XaraLX (834) to FreeBSD and
> >I'm getting a weird C++ warning and an error about undeclared macros:
> >
> snip
>
> >LocalEnvironment::GetNumberOfDecimalPlaces(UINT32*)':
> >localenv.cpp:150: error: `FRAC_DIGITS' undeclared (first use this function)
> >localenv.cpp:150: error: (Each undeclared identifier is reported only once
> >for each function it appears in.)
> >localenv.cpp:150: error: `nl_langinfo' undeclared (first use this function)
> >localenv.cpp: In static member function `static void
> >LocalEnvironment::GetThousandsSeparator(StringBase*)':
> >localenv.cpp:187: error: `THOUSANDS_SEP' undeclared (first use this
> >function)
> >localenv.cpp:187: error: `nl_langinfo' undeclared (first use this function)
> >localenv.cpp: In static member function `static void
> >LocalEnvironment::GetDecimalPointChar(StringBase*)':
> >localenv.cpp:221: error: `DECIMAL_POINT' undeclared (first use this
> >function)
> >localenv.cpp:221: error: `nl_langinfo' undeclared (first use this function)
> >gmake[2]: *** [localenv.o] Error 1
> >gmake[2]: Leaving directory `/tmp/xaralx-devel/work/XaraLX-0.4r834/wxOil'
> >gmake[1]: *** [all] Error 2
> >gmake[1]: Leaving directory `/tmp/xaralx-devel/work/XaraLX-0.4r834/wxOil'
> >gmake: *** [all-recursive] Error 1
> >*** Error code 2
> >
> >I just want to ask on this list, before investigating the problem
> >myself.
> >
> >Any ideas?
> >
> >
> Vasil,
>
> Looks like some code I added last week to get the correct characters to
> use for thousand separators and decimal points. Can you try #including
> <langinfo.h> at the top of localenv.cpp? BSD _should_ have an
> implementation (and googling "nl_langinfo BSD" finds some man-pages).
>
> Thanks,
> Luke
Yes, FreeBSD has an implementation of nl_langinfo, but it lacks the
macros you used, it has RADIXCHAR and THOUSEP but no equivalent for
FRAC_DIGITS.
see http://www.freebsd.org/cgi/cvsweb.cgi/src/include/langinfo.h
I checked that this simple program does not compile under Linux (Debian)
--- simple prog begins here ---
#include <langinfo.h>
#include <stdio.h>
int
main(int argc, char **argv)
{
printf("%s\n", nl_langinfo(FRAC_DIGITS));
printf("%s\n", nl_langinfo(THOUSANDS_SEP));
printf("%s\n", nl_langinfo(DECIMAL_POINT));
return 0;
}
--- simple prog ends here ---
it gives:
tmp.c:7: error: `FRAC_DIGITS' undeclared (first use in this function)
tmp.c:7: error: (Each undeclared identifier is reported only once
tmp.c:7: error: for each function it appears in.)
tmp.c:8: error: `THOUSANDS_SEP' undeclared (first use in this function)
tmp.c:9: error: `DECIMAL_POINT' undeclared (first use in this function)
and I see that only RADIXCHAR and THOUSEP are documented in
Debian's nl_langinfo(3).
What about using localeconv(3) instead of nl_langinfo(3)? The former
looks more consistent between different operating systems and has
documented all items you need. Following is a patch against localenv.cpp
that converts nl_langinfo usage to localeconv.
--- patch begins here ---
Index: localenv.cpp
===================================================================
--- localenv.cpp (revision 843)
+++ localenv.cpp (working copy)
@@ -100,6 +100,8 @@
/*
*/
+#include <locale.h>
+
#include "camtypes.h"
#include "localenv.h"
@@ -147,8 +149,10 @@
PORTNOTE("other","Removed GetProfileString usage")
#if defined(__WXGTK__)
- TRACEUSER( "luke", _T("iDigits = %d\n"), *nl_langinfo( FRAC_DIGITS ) );
- *DecimalPlaces = *nl_langinfo( FRAC_DIGITS );
+ struct lconv *lc;
+ lc = localeconv();
+ TRACEUSER( "luke", _T("iDigits = %d\n"), lc->frac_digits );
+ *DecimalPlaces = (UINT32)lc->frac_digits;
return;
#elif !defined(EXCLUDE_FROM_XARALX)
GetProfileString("intl", "iDigits", "2", TS, sizeof(TS));
@@ -184,7 +188,9 @@
PORTNOTE("other","Removed GetProfileString usage")
#if defined(__WXGTK__)
- TS[0] = ToUnicode( *nl_langinfo( THOUSANDS_SEP ) );
+ struct lconv *lc;
+ lc = localeconv();
+ TS[0] = ToUnicode( lc->thousands_sep[0] );
TS[1] = 0;
TRACEUSER( "luke", _T("sThousand = %s\n"), TS );
@@ -218,7 +224,9 @@
PORTNOTE("other","Removed GetProfileString usage")
#if defined(__WXGTK__)
- TS[0] = ToUnicode( *nl_langinfo( DECIMAL_POINT ) );
+ struct lconv *lc;
+ lc = localeconv();
+ TS[0] = ToUnicode( lc->decimal_point[0] );
TS[1] = 0;
TRACEUSER( "luke", _T("sDecimal = %s\n"), TS );
--- patch ends here ---
--
Vasil Dimov
gro.DSBeerF@dv
Testing can show the presence of bugs, but not their absence.
-- Edsger W. Dijkstra