【发布时间】:2013-07-30 13:08:11
【问题描述】:
我尝试通过在我的 configure.ac 文件中添加 AX_CXX_COMPILE_STDCXX_11 在 CDT 中启用 C++11。我试过在文件中移动它,这似乎是唯一不会出错的地方。我什至尝试添加可选的noext 标志,但这给了我一个语法错误。
我要编译的代码是:
#include <iostream>
#include <memory>
void
print_hello(){
std::unique_ptr<char[]> cha;
std::cout << "11?" << std::endl;
}
unique_ptr 当然是 c++11 的特性。
这就是我的 configure.ac 的样子:
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.64)
AC_INIT(fooProj, 1.0)
AC_CANONICAL_SYSTEM
AC_PROG_CXX
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11
dnl Initialize automake
AM_INIT_AUTOMAKE
dnl this allows us specify individual liking flags for each target
AM_PROG_CC_C_O
dnl Initialize Libtool
LT_INIT
dnl Check if Libtool is present
dnl Libtool is used for building share libraries
AC_PROG_LIBTOOL
AC_CONFIG_FILES(Makefile
exampleProgram/Makefile
libTestLib/Makefile
include/Makefile)
AC_OUTPUT
【问题讨论】:
-
你得到什么样的错误?将
-std=c++11传递给编译器还不够吗? -
我得到的错误是 unique_ptr 不是 std 的一部分。编译器标志就足够了,但这似乎不是正确的自动工具方式。
-
这个错误来自 Eclipse 吗?我的意思是,尽管有错误,代码是否可以编译?
-
不,它来自 g++,编译器没有通过
-std标志。 -
好的,现在我明白问题所在了。
标签: c++ c++11 eclipse-cdt autotools