My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 66668: NDK r9d libc++: compiler error when calling std::feof(), etc.
3 people starred this issue and may be notified of changes. Back to list
 
Reported by kmhofm...@gmail.com, Mar 5, 2014
Issue: Compiling below translation unit using Clang/libc++ distributed with NDK r9d results in a compiler error.

* Relevant parts of Application.mk:
APP_STL := c++_static
NDK_TOOLCHAIN_VERSION=clang
[...]

* The test translation unit (TEST.cpp):

#include <cstdio>
int foo()
{
	std::FILE* fp;
	return std::feof(fp) ? 1 : 0;
}

* The compiler error:

TEST.cpp:5:15: error: expected unqualified-id
 return std::(((fp)->_flags & 0x0020) != 0) ? 1 : 0;

This happens because $NDK_DIR/sources/cxx-stl/llvm-libc++/libcxx/include/cstdio includes <stdio.h>, which itself (located in $NDK_DIR/platforms/android-XX/arch-arm/usr/include/) defines feof() and other C functions (e.g. ferror(), clearerr(), fileno(), getc(), ...) as macros.
These macros are then extended to the above line, which, in combination with the std:: namespace prefix, does not result in a valid expression.

Expected result: calls to std::feof(), etc. compile correctly.
Mar 5, 2014
Project Member #1 nara...@google.com
looks cstdio needs to #undef these macros after "capturing" them.
Owner: andrewhs...@google.com
Cc: nara...@google.com e...@google.com bcch...@google.com
Mar 6, 2014
Project Member #2 andrewhs...@google.com
Fixed by Carl's patch (b.android.com/36496 #33) which is submitted on his behalf: https://android-review.googlesource.com/#/c/84206.  

Status: FutureRelease
Cc: di...@android.com carl@norum.ca
Jul 17, 2014
Project Member #3 andrewhs...@google.com
(No comment was entered for this change.)
Status: Released
Sign in to add a comment

Powered by Google Project Hosting