Blog:https://blog.csdn.net/fengbingchun
|
|
---|
C++/C++11/C++14/C++17/C++20's usage
Home Page: http://blog.csdn.net/fengbingchun/article/category/725584
博主你好,我尝试在Ubuntu18.04下编译linux_cmake_CppBaseTest,结果发现编译出错了,似乎是因为编译选项添加有问题,导致没有识别出C++11及以上版本,博主能否帮忙看一下?
这是错误信息:
/home/lhh/Documents/learning/coding/Messy_Test/demo/CppBaseTest/effective_modern_cplusplus.cpp: In member function ‘double effective_modern_cplusplus_::Point16::distanceFromOrigin() const’:
/home/lhh/Documents/learning/coding/Messy_Test/demo/CppBaseTest/effective_modern_cplusplus.cpp:633:15: error: ‘sqrt’ is not a member of ‘std’
return std::sqrt((xx) + (yy));
^~~~
/home/lhh/Documents/learning/coding/Messy_Test/demo/CppBaseTest/effective_modern_cplusplus.cpp:633:15: note: suggested alternative: ‘sort’
return std::sqrt((xx) + (yy));
/home/lhh/Documents/learning/coding/Messy_Test/demo/CppBaseTest/effective_modern_cplusplus.cpp: In function ‘int effective_modern_cplusplus_::test_item_32()’:
/home/lhh/Documents/learning/coding/Messy_Test/demo/CppBaseTest/effective_modern_cplusplus.cpp:1244:20: error: ‘bind’ is not a member of ‘std’
auto func7 = std::bind([](const std::unique_ptr& pw) {return pw->isValidated() && pw->isArchived(); }, std::make_unique()); // C++11
^~~~
/home/lhh/Documents/learning/coding/Messy_Test/demo/CppBaseTest/effective_modern_cplusplus.cpp:1244:20: note: suggested alternative: ‘find’
auto func7 = std::bind([](const std::unique_ptr& pw) {return pw->isValidated() && pw->isArchived(); }, std::make_unique()); // C++11
On Mac OS:
demo/CppBaseTest/cplusplus_secure_coding.cpp:439:25: error: use of undeclared identifier 'aligned_alloc'
float* array = (float*)aligned_alloc(16, arr_size * sizeof(float));
Failed to build CppBaseTest due to some definition missing, fixed by the below patch. Please help review.
diff --git a/demo/CppBaseTest/effective_modern_cplusplus.cpp b/demo/CppBaseTest/effective_modern_cplusplus.cpp
index 07c3e04..2dbf41d 100644
--- a/demo/CppBaseTest/effective_modern_cplusplus.cpp
+++ b/demo/CppBaseTest/effective_modern_cplusplus.cpp
@@ -1,6 +1,8 @@
#include "effective_modern_cplusplus.hpp"
#include <cstddef>
#include <cstdint>
+#include <cmath>
+#include <functional>
#include <iostream>
#include <array>
#include <vector>
diff --git a/demo/CppBaseTest/set.cpp b/demo/CppBaseTest/set.cpp
index a0ee1f1..1749cc0 100644
--- a/demo/CppBaseTest/set.cpp
+++ b/demo/CppBaseTest/set.cpp
@@ -7,6 +7,7 @@
#include <functional>
#include <iomanip>
#include <algorithm>
+#include <cmath>
// Blog: http://blog.csdn.net/fengbingchun/article/details/63268962
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.