简体   繁体   English

android中的g ++和ubuntu中的g ++有什么区别?

[英]what is the difference between g++ in android and g++ in ubuntu?

I try to the same simple code, that which one is in the Android(4.2.2) and another one is in the Ubuntu(15.04), but with a similar code I get error in the Ubuntu.我尝试使用相同的简单代码,其中一个在 Android(4.2.2) 中,另一个在 Ubuntu(15.04) 中,但是使用类似的代码我在 Ubuntu 中出错。 Also in the Android works very well, but in the Ubuntu even does not compiling.同样在Android 中运行良好,但在Ubuntu 中甚至无法编译。

initialize without / = / syntax and uses / ( ) / syntax不使用 / = / 语法进行初始化并使用 / ( ) / 语法

code :代码 :

int i(1); /// ok
char c('a'); /// ok
float f(4.444); /// ok
double d(4.34343433434); /// ok
char* cs("stack over flow"); /// ok
char I[]("stack over flow"); /// can not initialize by g++ in Ubuntu

in Android (c4droid):在 Android (c4droid) 中:

在此处输入图片说明

in Ubuntu (code block):在 Ubuntu 中(代码块):

在此处输入图片说明

both of them use the g++ compiler他们都使用 g++ 编译器

g++ (Ubuntu 4.9.2-10ubuntu13) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

在此处输入图片说明

In standard c++ built-in arrays cannot be constructed with constructor-like call.在标准的 C++ 中,内置数组不能用类似构造函数的调用来构造。 You should use {} brackets instead.您应该改用{}括号。 It's very similar to templates.它与模板非常相似。 Non-type template arguments can't be deduced from constructors (just like any template arguments)不能从构造函数推导出非类型模板参数(就像任何模板参数一样)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM