Hi,
I found a strange behaviour of GCC. In few words, I can successfully compile with GCC 5 or GCC 4 while I cannot compile with GCC 6.
From GCC manual: In GCC 6 the default mode for C++ is now -std=gnu++14 instead of -std=gnu++98 while GCC 5 the default mode for C is now -std=gnu11 instead of -std=gnu89.
I think that using c++14 causes different behaviour with the same code with respect to previous GCC versions.
I found the source of problem at least for one error during compiling with GCC 6:
[CODE]system/core/adb/transport.c:807:9: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation] if (error_out)[/CODE]
is detected by GCC 6 thank to a new warning -Wmisleading-indentation added to -Wall option https://gcc.gnu.org/gcc-6/porting_to.html while is not detected by GCC 5 or lower version.
The current source code:
[CODE]
if (error_out)
error_out = "insufficient permissions for device";
continue;
[/CODE]
it should be:
[CODE]
if (error_out)
{
error_out = "insufficient permissions for device";
}
continue;[/CODE]
with brackets for a better clearness https://stackoverflow.com/questions/2125066/is-it-bad-practice-to-use-an-if-statement-without-brackets#2125207
After that I corrected this small error, another error appears related to invalid type conversion from const uint16_t to const char16_t:
[CODE]
frameworks/base/libs/androidfw/AssetManager.cpp: In member function ‘android::String8 android::AssetManager::getPkgName(const char*)’:
frameworks/base/libs/androidfw/AssetManager.cpp:480:63: error: invalid conversion from ‘const char16_t*’ to ‘const uint16_t* {aka const short unsigned int*}’ [-fpermissive]
const uint16_t* str = tree.getAttributeStringValue(idx, &len);
~~~~~~~~~~~~~~~~~~^
frameworks/base/libs/androidfw/AssetManager.cpp:481:46: error: invalid conversion from ‘const uint16_t* {aka const short unsigned int*}’ to ‘const char16_t*’ [-fpermissive]
pkgName = (str ? String8(str, len) : String8());
^
In file included from frameworks/base/include/androidfw/Asset.h:30:0,
from frameworks/base/libs/androidfw/AssetManager.cpp:26:
system/core/include/utils/String8.h:56:33: note: initializing argument 1 of ‘android::String8::String8(const char16_t*, size_t)’
explicit String8(const char16_t* o, size_t numChars);
[/CODE]
In this case the error is related to android utils library android::String8 which uses different return type. So, I think that such problem should be not related to ubuntu touch, but to general android and CM. Is there a way to compile android or CM with GCC 6?
I search on the web about this behaviour without success.
Thank you