Android: swift compiler is not including C system header paths


(Eric Wing) #1

Using Swift/Android, the swift compiler is not including the C
standard library system headers path from the Android NDK. This is
causing me problems when I include something in my bridging header
that happens to include a header from the C standard library. This
blocks the compile from working.

I temporary manually added an include path to the list of build flags
which works around the problem. But now I’m getting warnings about
“unknown attribute” for alloc_size (<string.h> goes to <malloc.h> and
hits a case in the declaration of memalign.) This just a warning and
has not broken my program in any way I can tell.

However, the strangest thing for me is that I didn’t use to have any
of these problems. I used to just be able to build without adding the
extra include path. I recently rebuilt my Android compiler without
updating my source code snapshot. My intention was to clean up a build
so I can distribute the binary to a clean Linux system. But now I
started getting this behavior, and I can’t for the life of me figure
out what I may have changed.

Anyway, I’m posting here hoping maybe somebody knows something about
this. And also, maybe to get better insight of what the swift compiler
is supposed to do about the NDK system header paths. (Is it supposed
to automatically include them? I think it is a good idea. Figuring out
where everything is manually in the NDK is a PITA.)