Why does this compile?
Russell Haley
russ.haley at gmail.com
Tue Sep 26 05:45:43 UTC 2017
You guys are awesome. Thanks so much!
Russ
On Mon, Sep 25, 2017 at 9:56 PM, Mark Millard <markmi at dsl-only.net> wrote:
> On 2017-Sep-25, at 9:38 PM, Russell Haley <russ.haley at 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
>
More information about the freebsd-arm
mailing list