Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Sep 2017 22:45:40 -0700
From:      Russell Haley <russ.haley@gmail.com>
To:        Mark Millard <markmi@dsl-only.net>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>
Subject:   Re: Why does this compile?
Message-ID:  <CABx9NuR5u=Jn%2Bi-uGPeNXTnprWs4CY1GDhnA1C7UgZtYE8QNYQ@mail.gmail.com>
In-Reply-To: <E05945D2-474A-4025-A221-7F1FCB7AF25C@dsl-only.net>
References:  <CABx9NuSzSzK87WF07S0B2aZpddKxYJf69kR2gWqBmHxaEQO6JA@mail.gmail.com> <E05945D2-474A-4025-A221-7F1FCB7AF25C@dsl-only.net>

next in thread | previous in thread | raw e-mail | index | archive | help
You guys are awesome. Thanks so much!

Russ

On Mon, Sep 25, 2017 at 9:56 PM, Mark Millard <markmi@dsl-only.net> wrote:
> On 2017-Sep-25, at 9:38 PM, Russell Haley <russ.haley@gmail.com> wrote:
>
>> I'm trying to compile the new dotnet core 2.0 and I've run into a C
>> problem I don't understand. Since I ran the code to check it on my arm
>> board, I'm going to ask here (the most knowledgeable fbsd C people I
>> could ask).
>>
>> The cmake file is trying to test for a linux struct in_pktinfo:
>>
>> check_c_source_compiles(
>>    "
>>    #include <${SOCKET_INCLUDES}>
>>    int main()
>>    {
>>        struct in_pktinfo;
>>        return 0;
>>    }
>>    "
>>    HAVE_IN_PKTINFO)
>>
>> SOCKET_INCLUDES resolves to netinet/in.h so the final source is:
>>
>> #include <netinet/in.h>
>>
>> int main()
>> {
>>    struct in_pktinfo;
>>    return 0;
>> }
>>
>> This compiles on FreeBSD current and apparently on 11 too. That's a
>> bad thing because it's supposed to fail. I checked in.h and there is
>> no struct for in_pktinfo. Not surprisingly, if I remove the include
>> altogether, it still compiles.
>
> struct in_pktinfo;
>
> declares but does not define the struct type. Not even
> the size is known --but nothing is done that needs
> to use even the size.
>
> By contrast the below would need the definition
> of the struct type in question:
>
> #include <netinet/in.h>
>
> int main()
> {
>    struct in_pktinfo struct_instance;
>    return 0;
> }
>
>> I assume then that the original author made a mistake? My C is too
>> weak and most of my searches don't turn up anything close to what I'm
>> looking for.
>
> The program needs to have something that requires
> seeing the definition of the type, such as needing
> its size.
>
>> Any suggestions would be awesome.  :)
>
> check_c_source_compiles(
>    "
>    #include <${SOCKET_INCLUDES}>
>    int main()
>    {
>        struct in_pktinfo struct_instance;
>        return 0;
>    }
>    "
>    HAVE_IN_PKTINFO)
>
>
> ===
> Mark Millard
> markmi at dsl-only.net
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CABx9NuR5u=Jn%2Bi-uGPeNXTnprWs4CY1GDhnA1C7UgZtYE8QNYQ>