Use of static_assert forbidden in Android project - android-ndk

I am porting some C++ code to Android. One of the source files includes a webrtc header file that causes error during compilation. I have reduced the problem to this simple code:
template <class T, int n>
struct DefaultDeleter<T[n]> {
// Never allow someone to declare something like scoped_ptr<int[10]>.
static_assert(sizeof(T) == -1, "do not use array with size as type");
};
The error I get is:
[armeabi-v7a] Compile++ thumb: dummyclient <= dummy.cpp
dummy.cpp:7:3: warning: identifier 'static_assert' will become a keyword in C++0x [-Wc++0x-compat]
dummy.cpp:5:8: error: 'DefaultDeleter' is not a template
dummy.cpp:7:17: error: expected identifier before 'sizeof'
dummy.cpp:7:17: error: expected ',' or '...' before 'sizeof'
dummy.cpp:7:70: error: ISO C++ forbids declaration of 'static_assert' with no type [-fpermissive]
The same code compiles fine on Windows and Linux. Is there some compiler settings that are required for Android? Regards.

You need to pass the CPPFLAG -std=c++11.

Related

Connecting Sparkfun ESP8266 Thing to Azure IoT Hub

I am currently trying to connect my Sparkfun ESP8266 Thing to my Azure IoT Hub. I have successfully set up my hub, and am following this tutorial on how to connect the Thing to my Azure IoT Hub: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-sparkfun-esp8266-thing-dev-get-started
Unfortunately I keep getting the error:
'StaticJsonBuffer' was not declared in this scope
Arduino: 1.8.5 (Windows 10), Board: "SparkFun ESP8266 Thing, 80 MHz, 512K (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
Build options changed, rebuilding all
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino: In function 'bool readMessage(int, char*)':
message:46: error: 'StaticJsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:46:5: note: suggested alternative:
In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.hpp:10,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.h:9,
from C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:2:
C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'
class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
^
message:46: error: 'jsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
message:74: error: 'class ArduinoJson::JsonObject' has no member named 'printTo'
root.printTo(payload, MESSAGE_MAX_LEN);
^
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino: In function 'void parseTwinMessage(char*)':
message:80: error: 'StaticJsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:80:5: note: suggested alternative:
In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.hpp:10,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.h:9,
from C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:2:
C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'
class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
^
message:80: error: 'jsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
message:82: error: 'class ArduinoJson::JsonObject' has no member named 'success'
if (!root.success())
^
message:88: error: 'ArduinoJson::Internals::enable_if >::type' has no member named 'success'
if (root["desired"]["interval"].success())
^
exit status 1
'StaticJsonBuffer' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I have changed the DEVICE_ID from "SparkFun ESP8266 Thing Dev" to "SparkFun ESP8266 Thing", and am using simulated data.
Any help with this would be much appreciated!
The reason for this error is that you install the ArduinoJson version >= 6. Default version 6.2.3-beta will be installed but from version 6 and higher JsonBuffer is replaced with JsonDocument. It is also indicate in the error message:
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:46:5:
note: suggested alternative:
In file included from
C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0
To solve this issue you can roll back to the previous version. Version 5.13.2 works for me.
Reference issue on ArduinoJson repo and issue on iot-hub-feather-huzzah-client-app repo.

Install OpenCV-2.4.9 on CentOS 7 (PC)

I'm trying to install OpenCV-2.4.9 on CentOS 7 (PC) however getting error after 16% when running "make" command. I leave default configuration for OpenCV.
make
...
[ 16%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_v4l.cpp.o /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:306:29: error: field ‘capability’ has incomplete type
struct video_capability capability;
^ /opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:307:29: error: field ‘captureWindow’ has incomplete type
struct video_window captureWindow;
....
....
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp: In function ‘void icvCloseCAM_V4L(CvCaptureCAM_V4L*)’:
/opt/opencv-2.4.9/opencv/modules/highgui/src/cap_v4l.cpp:2812:46: error: ‘CvCaptureCAM_V4L’ has no member named ‘memoryBuffer’
It seems that the define HAVE_CAMV4L has the value 1, if you look in the file modules/highgui/src/cap_v4l.cpp looking for the structure definition at the row 306. If the compilation fails at that point this means that the video4linux development configuration is corrupted.
Using google I have found that the OpenCV Bug #1357 is described as follow:
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L) succeeds even though linux/videodev.h doesn't exist on the system. (Bug #1357)
http://code.opencv.org/issues/1357
Anyway the solution is described at the same URL for "HAVE_CAMV4L gets set incorrectly": "Setting it to FALSE in CMakeLists.txt fixes the problem".

not building with ./build_native.sh and android- ndk-r8 in cocos2d-x

I have downloaded the source code for a projet in cocos2d-x.
I am using the ./build_native.sh from the Hello World example, which is sure it works.
Yet again I am getting this error when compiling:
Gdbserver : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile++ thumb : cocos2d <= CCGrabber.cpp
jni/../../libs/cocos2dx/effects/CCGrabber.cpp: In constructor 'cocos2d::CCGrabber::CCGrabber()':
jni/../../libs/cocos2dx/effects/CCGrabber.cpp:46:32: error: 'glGenFramebuffersOES' was not declared in this scope
jni/../../libs/cocos2dx/effects/CCGrabber.cpp: In member function 'void cocos2d::CCGrabber::grab(cocos2d::CCTexture2D*)':
jni/../../libs/cocos2dx/effects/CCGrabber.cpp:61:47: error: 'glBindFramebufferOES' was not declared in this scope
jni/../../libs/cocos2dx/effects/CCGrabber.cpp:65:26: error: 'glFramebufferTexture2DOES' was not declared in this scope
jni/../../libs/cocos2dx/effects/CCGrabber.cpp:68:63: error: 'glCheckFramebufferStatusOES' was not declared in this scope
jni/../../libs/cocos2dx/effects/CCGrabber.cpp: In member function 'void cocos2d::CCGrabber::beforeRender(cocos2d::CCTexture2D*)':
jni/../../libs/cocos2dx/effects/CCGrabber.cpp:88:47: error: 'glBindFramebufferOES' was not declared in this scope
jni/../../libs/cocos2dx/effects/CCGrabber.cpp: In member function 'void cocos2d::CCGrabber::afterRender(cocos2d::CCTexture2D*)':
jni/../../libs/cocos2dx/effects/CCGrabber.cpp:113:50: error: 'glBindFramebufferOES' was not declared in this scope
jni/../../libs/cocos2dx/effects/CCGrabber.cpp: In destructor 'virtual cocos2d::CCGrabber::~CCGrabber()':
jni/../../libs/cocos2dx/effects/CCGrabber.cpp:127:35: error: 'glDeleteFramebuffersOES' was not declared in this scope
I searched and found this sollution. But it does not work for me. I am still getting the same error. Maybe it is different in ndk-r8 whilst the sollution is for ndk-r7.
Any help?
Your android sdk version must bigger than 2.2.because from 2.2,the android begin to support opengl es 2.0,and the cocos2d-x 2.0 use the opengles 2.0 to render

C++ syntax error: missing ';' before 'constant'

I have the following line of code in my program -
typedef GROUP ACE_SOCK_GROUP;
That gives the following warnings and errors -
Warning 181 warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared
Error 182 error C2143: syntax error : missing ';' before 'constant'
Error 183 error C2059: syntax error : 'constant'
The definition of GROUP is given in another file that is included by my program as -
typedef unsigned int GROUP;
What does 'constant' here refer to?
What could be causing the error?
What is the warning indicating
I am using Visual Studio 2008 and found the definition of GROUP using the F12 function
The code is correct.
You're forgetting to include the file where GROUP is defined.
You can try a simple test to confirm this is the issue:
typedef unsigned int GROUP;
typedef GROUP ACE_SOCK_GROUP;
If this compiles, and it will, that means that the previous definition of GROUP is not seen. You need to include the file with the definition before defining ACE_SOCK_GROUP.

when I include atomic.h, GCC says No such file, why?

I want to use atomic API, and I include . I don't know how to use it! Thank you!
I have it in /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/atomic.h.
I also add -I/usr/src/linux-headers-2.6.28-11/arch/x86/include/ and -I/usr/src/linux-headers-2.6.28-11/include.
Some other errors is produced because of -DCONFIG_X86_32 and -D__KERNEL__ macro undefined.
Then I define the two macros,
some errors occurred:
/usr/src/linux-headers-2.6.28-11/include/linux/cpumask.h:600:37: error: "and" may not appear in macro parameter list
/usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/processor.h:159:1: warning: "cache_line_size" redefined
/usr/src/linux-headers-2.6.28-11/include/linux/cache.h:64:1: warning: this is the location of the previous definition
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected identifier before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected `}' before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected unqualified-id before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:18: error: expected declaration before ‘}’ token
My system is ubuntu 9.04 running on Virtualbox3.0.
If you know where the file is on your HD, then you say gcc mySource.c -I/path/to/atomic
note that this assumes you include "atomic" directly. and not "some/path/atmomic.h"

Resources