On Fri, 15 Jun 2007, Alexey Lyubimov wrote: > Hello! > When I try to compile very simple example from > gettext's tutorial - I get compilation errors using > gcc or g++. > > Here is the source code: > ----------------------------- > main.c or main.cc > > #include <libintl.h> > #include <locale.h> > #include <stdio.h> > #include <stdlib.h> > > #define _(aString) gettext(aString) > > int > main(void) > { > setlocale(LC_ALL, ""); > bindtextdomain("gt", "/usr/share/locale"); > textdomain("gt"); > printf(_("Hello, world!\n")); > exit(0); > } > ---------------------------------- > > 1) I CAN NOT build the test program with MinGW (-mno-cygwin): > > $ gcc -o gt -mno-cygwin -g main.c > > main.c:3:21: libintl.h: No such file or directory > [snip]
Not surpising, as there is no MinGW gettext visible to gcc on your system. > 2) I CAN NOT build the test program as C-program (with gcc): You must mean a *Cygwin* C program. > $ gcc -o gt -g main.c > In file included from /usr/include/libintl.h:22, > from main.c:3: > /usr/include/locale.h:26: error: syntax error before > "struct" > > I think it's because GCC doesn't understand > _BEGIN_STD_C, _END_STD_C macros used inside "locale.h" Hmm, those ought to have been defined in _ansi.h. Try running "gcc -E main.c" and see what exactly is produced by the macro expansion. > 3) I CAN NOT build the test program as C++-program > (with g++): > > g++ -o gt -g main.cc > In file included from /usr/include/sys/config.h:167, > from /usr/include/_ansi.h:16, > from /usr/include/locale.h:10, > from /usr/include/libintl.h:22, > from main.cc:3: > /usr/include/cygwin/config.h:18: error: expected > constructor, destructor, or type conversion before "extern" > /usr/include/cygwin/config.h:18: error: expected `,' > or `;' before "extern" > > What is wrong? What is the workaround? Not sure. Builds fine on my system, with both gcc and g++, with "main.c or main.cc" commented out... However, a WAG: when you say > Here is the source code: > ----------------------------- > main.c or main.cc > > #include <libintl.h> Do you mean that the first line of your program is actually "main.c or main.cc"? If not, what is the first line? I get a similar message if I put something nonsensical there, like "class". Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ [EMAIL PROTECTED] | [EMAIL PROTECTED] ZZZzz /,`.-'`' -. ;-;;,_ Igor Peshansky, Ph.D. (name changed!) |,4- ) )-,_. ,\ ( `'-' old name: Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! Freedom is just another word for "nothing left to lose"... -- Janis Joplin -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/