rockdaboot / mget

Multithreaded metalink/file/website downloader (like Wget) and C library
GNU Lesser General Public License v3.0
112 stars 19 forks source link

libtest.c fail in Cygwin #24

Closed gvanem closed 9 years ago

gvanem commented 9 years ago

Hi Tim.

I've given up trying building the whole thing with MingW/MSVC. Cygwin works fine except for this in tests/libtest.c:

gcc -c -Wall -DHAVE_CONFIG_H=1 -DHAVE_LIBPTHREAD=1 -I. -I./include -I./libmget -I./src -std=gnu99  -g3 -O0 tests/libtest.c
tests/libtest.c: In function '_server_thread':
tests/libtest.c:89:30: error: unknown field 'sa_handler' specified in initializer
tests/libtest.c:89:30: warning: missing braces around initializer
tests/libtest.c:89:30: warning: (near initialization for '(anonymous).<anonymous>')

I use this diff to fix it:

--- Git-latest/tests/libtest.c  2014-08-19 22:42:21 +0000
+++ tests/libtest.c     2014-08-23 14:48:18 +0000
@@ -85,8 +85,10 @@
        unsigned it;
        int byterange, authorized;
        time_t modified;
+       struct sigaction sa;

-       sigaction(SIGTERM, &(struct sigaction) { .sa_handler = nop }, NULL);
+       sa.sa_handler = nop;
+       sigaction(SIGTERM, &sa, NULL);

        while (!terminate) {
                mget_tcp_deinit(&tcp);

My Cygwin uses gcc 4.5.3. Is that too old for this?

rockdaboot commented 9 years ago

Looks like the compiler is not C99 compliant. At least gcc 4.5.3 claims to have full C99 support. My Cygwin Setup installs gcc 4.8.3 here (Selection 'Curr'). Why do you have 4.5.3 ?

gvanem commented 9 years ago

Why do you have 4.5.3 ?

Why not. Why limit Mget to (almost only) Unix/Posix platforms. Only Cygwin works on Windows now AFAICS. It would be way cool if Mget could be built on Windows with MingW+MSVC too. It looks like an interesting proggy.

Btw. these bleeding-edge gcc-features are just overrated IMHO. Makes very long lines in .c-files too. E.g.:

static void print_status(DOWNLOADER *downloader, const char *fmt, ...) G_GNUC_MGET_NONNULL_ALL G_GNUC_MGET_PRINTF_FORMAT(2,3);

A 155 character long line!

rockdaboot commented 9 years ago

I was just wondering, why your CygWin offers 4.5.3 - mine even doesn't offer this version of gcc. I don't want to limit Mget to Unix (this issue is not platform dependent - it is C99), that is just the platform I can work and test on. I just have Win7 in a VM - and that is very clumsy. I personally heavily use many C99 features and I tend to use the latest technique / systems (will use C11 as soon this is available in Debian unstable). I know Microsoft ignores standards and refuses to adopt C99 features. C is dead for Microsoft - that is simply what they say. So why should I bother with MSVC ? CygWin is ok and if you like to works on patches for a MinGW Cross compilation, these patches will be very welcome.

The reason for short lines are old monitors (especially the green ones ;-) are not capable to show more columns. Today you can get a full HD monitor for less than 100 € or $ (new). No need to limit lines any more. Line breaking seems very ugly und unreadable to me (just my personal point of view). The mentioned gcc-features are maybe over-rated, but i like to play with them. Clang/LLVM also knows and uses them (also Intel and IBM C compilers).

rockdaboot commented 9 years ago

I can't reproduce the problem with gcc 4.5.4.