Subject: Re: example/direct_tcpip.c missing header

Re: example/direct_tcpip.c missing header

From: Guenter <lists_at_gknw.net>
Date: Wed, 02 Jun 2010 14:19:11 +0200

Am 02.06.2010 12:19, schrieb Mark Smith:
> Would it be better to create a new file, such as example.h, in order to keep
> the example code clean and hide the actual build requirements in a header
> that's common to all the examples and can contain whatever #ifdefs are
> needed, be they application-like or library-like?
That sounds fine at first glance, but doesnt make things simpler finally
because this example.h still needs to pull its info from
libssh2_config.h or else we end up same with a hand-weaked list of
platform-specific ifdefs - just in another file which IMO adds complexity.
On the other side what's wrong with having a list of ifdef'd include
statements of possibly needed headers? If someone wants to take such a
sample and isolate it from the libssh2 project then we should assume he
knows his own platform well, and thus only need to delete the obsolete
ifdefs, or just provide the defines for his platform via CFLAGS where
libssh2_config.h gives him the idea what he needs.
On the other side the way Peter actually supports is that we have ifdefs
for two widely spreaded platforms, and for every other platform the
developer sees the sample fail to compile with messages like this:

mwccnlm -O2 -DNDEBUG -DNETWARE -nostdinc -msgstyle gcc -gccinc -inline
off -opt nointrinsics -proc 586 -relax_pointers -align 4 -D_POSIX_SOURCE
-I.. -I../../include
-ID:/projects/sdks/openssl_nw-bsd-0.9.8n/outinc_nw_libc
-ID:/projects/sdks/openssl_nw-bsd-0.9.8n/outinc_nw_libc/openssl
-ID:/projects/srcs/zlib-1.2.5 -ID:/Novell/ndk/libc/include -c
../../example/direct_tcpip.c -o release/direct_tcpip.o
..\..\example\direct_tcpip.c:55: undefined identifier 'fd_set'
..\..\example\direct_tcpip.c:56: expression syntax error
..\..\example\direct_tcpip.c:57: expression syntax error
..\..\example\direct_tcpip.c:58: expression syntax error
..\..\example\direct_tcpip.c:66: expression syntax error
..\..\example\direct_tcpip.c:170: undefined identifier 'sockopt'

and needs to crawl through system headers headers then in order to find
the missing bits + nothing in first place which helps here - you need to
grep through the headers.

> Also, to cope with unmet requirements, isn't #error designed for that?
nope - then we have again the prob that 'make examples' breaks, and all
folowing examples which might be listed after the failing one are not
compiled; if we want to solve this prob we need to go another route,
f.e. currently there are only one or two samples with special
requirements which also depend on headers available IIRC - so we could
do something like:
#include <stdio.h>
#ifdef HAVE_NON_STANDARD_H
....
sample ...
and at the end:
#else
int main() {
   printf("This sample does not work on this platform because
non_standard.h is not available!\n");
   return 999;
}
#endif

this way we could build all samples without compilation breakage, and a
test script could even detect return code 999 and print "test skipped".

just my 3ct.

GŁn.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-06-02