Hey, all!

On Wed, Sep 30, 2015 at 4:55 AM, ??? <jihwan.seo at samsung.com> wrote:

> Hi Gabriel
>
>
>
> since the flag(TCP_ADAPTER) is already contained in CA(Connectivity
> Abstraction) layer.
>
> your build should have built without -DTCP_ADAPTER in your flag.
>

Oh, iotivity builds just fine, it's just that the flags behind #ifdef
TCP_ADAPTER are not available. For example, if you look at octypes.h,

https://gerrit.iotivity.org/gerrit/gitweb?p=iotivity.git;a=blob;f=resource/csdk/stack/include/octypes.h;h=b82d1beca835b0e34d042c26a74e35b4877828f1;hb=refs/heads/1.0.0-dev#l430

you can see that CT_ADAPTER_TCP is only defined if the source file that
includes octypes.h is compiled with -DTCP_ADAPTER. If not, then, although
iotivity was compiled with -DTCP_ADAPTER, if you don't also compile your
own project with -DTCP_ADAPTER, then CT_ADAPTER_TCP will not be defined.

To put it another way: Let's say I write an application using iotivity. I
want my application to have TCP support. So, I build iotivity without any
special command line, and it has TCP support by default. Great!

Now, I start writing my application:

#include <ocstack.h>
#include <octypes.h>
...
OCDoResource(..., CT_ADAPTER_TCP, ... );
...

When I compile my application, I get "error: ?CT_ADAPTER_TCP? undeclared".
What?! Why is CT_ADAPTER_TCP undefined? I thought iotivity had TCP support.
Strange. Then I look at octypes.h and I see this:

#ifdef TCP_ADAPTER
CT_ADAPTER_TCP =  ( 1 << 20 ),
#endif

Oh, OK, so that means that if I want to use iotivity's TCP support in my
own application, I have to compile my own application with -DTCP_ADAPTER.

What I'm saying is that this is not how it's supposed to work. Normally,
octypes.h includes a file called config.h which has #define TCP_ADAPTER
inserted into it before compilation of iotivity starts. That way, I don't
need to compile my own project with -DTCP_ADAPTER, because TCP_ADAPTER is
#define-ed in config.h. This is how most libraries ship.

and the build is working find in our test.
>
Yes, your build is working fine, but the resulting library cannot be used
by any application that wants TCP support, unless you tell the developers
to compile their own project with -DTCP_ADAPTER. That's why a config.h
which is #include-ed from octypes.h and any other header file documented
under resource/csdk/doc needs to be created during the build process,
containing all the #define statements necessary to reflect how iotivity
itself was built.


> again..what is the Scons *full* command you used?
>
My build is not failing, but the resulting header files are useless, so the
command line is irrelevant. Nevertheless, here it is:

JAVA_HOME=/ scons liboctbstack libconnectivity_abstraction libcoap c_common
libocsrm


> PS. we are checking it as below commands.
>
> >scons TARGET_OS=linux     // default
>
> >scons TARGET_OS=linux TARGET_TRANSPORT=ALL  // ALL
>
Like I said, the result of the above commands is a perfectly correct build
with perfectly incorrect header files. You need to test with other
applications, not just the library itself. Put yourself into the place of
an application developer trying to use your library. If she builds your
library knowing that it has TCP support by default, she expects to be able
to use CT_ADAPTER_TCP in her own application without having to build her
own project with any special flags, like -DTCP_ADAPTER.

HTH,



Gabriel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.iotivity.org/pipermail/iotivity-dev/attachments/20150930/8de0c62b/attachment.html>

Reply via email to