C++17 - The Complete Guide by Nicolai M. Josuttis
http://www.josuttis.com/cppstd17/
C++17 - The Complete Guide clang++とg++でコンパイルしてみた(まとめ)
https://qiita.com/kaizen_nagoya/items/c000f307e642990781e1
目的(purpose)
C++17 - the complete guideコンパイル記録は、コンパイラおよび対応標準、コンパイラの版により、コンパイルエラーMessageの違いを記録し、どのエラーが出たら、どの版またはどの対応標準にすればエラーが少なくなるかを考察するための資料の第一歩です。
成果(outcome)
(1)コンパイラの種類、対応標準の違いによってエラーの数が違う。
(2)同じエラーであってもMessageの表現が違う。
(3) Error Messageのネットで検索する際に役立つ。
編纂器(compiler)
clang++
clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
g++
g++ (Homebrew GCC 8.1.0) 8.1.0
Copyright (C) 2018 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.
#編纂実行(Compile and go) lang
##一覧(list)
clang++ | g++ | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
filesystem | error | warning | link error | execute error | 出力・備考 | error | warning | link error | execute error | 出力・備考 | c/g |
checkpath.cpp | 3 | 1 | コンパイルエラーとリンクエラー | ||||||||
createfiles.cpp | 3 | 1 | コンパイルエラーとリンクエラー | ||||||||
switchinit.cpp | 6 | 1 | std::experimentalを注釈にすると上記リンクエラー | コンパイルエラーとリンクエラー |
###checkpath
clang++ filesystem/checkpath.cpp -std=c++2a -Wall
filesystem/checkpath.cpp:3:10: error: 'filesystem' file not found with <angled> include; use "quotes" instead
#include <filesystem>
^~~~~~~~~~~~
"filesystem"
In file included from filesystem/checkpath.cpp:3:
filesystem/filesystem:1:1: error: unknown type name 'filesystem'
filesystem/checkpath.cpp
^
filesystem/filesystem:1:11: error: expected unqualified-id
filesystem/checkpath.cpp
^
3 errors generated.
g++ filesystem/checkpath.cpp -std=c++2a -Wall
Undefined symbols for architecture x86_64:
"std::filesystem::__cxx11::directory_iterator::operator*() const", referenced from:
_main in ccgtVCG6.o
"std::filesystem::status(std::filesystem::__cxx11::path const&)", referenced from:
std::filesystem::exists(std::filesystem::__cxx11::path const&) in ccgtVCG6.o
std::filesystem::is_directory(std::filesystem::__cxx11::path const&) in ccgtVCG6.o
std::filesystem::is_regular_file(std::filesystem::__cxx11::path const&) in ccgtVCG6.o
"std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options, std::error_code*)", referenced from:
std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&) in ccgtVCG6.o
"std::filesystem::__cxx11::directory_iterator::operator++()", referenced from:
_main in ccgtVCG6.o
"std::filesystem::__cxx11::path::_M_split_cmpts()", referenced from:
std::filesystem::__cxx11::path::path<char*, std::filesystem::__cxx11::path>(char* const&, std::filesystem::__cxx11::path::format) in ccgtVCG6.o
"std::filesystem::file_size(std::filesystem::__cxx11::path const&)", referenced from:
_main in ccgtVCG6.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
###createfiles
clang++ filesystem/createfiles.cpp -std=c++2a -Wall
filesystem/createfiles.cpp:4:10: error: 'filesystem' file not found with <angled> include; use "quotes" instead
#include <filesystem>
^~~~~~~~~~~~
"filesystem"
In file included from filesystem/createfiles.cpp:4:
filesystem/filesystem:1:1: error: unknown type name 'filesystem'
filesystem/checkpath.cpp
^
filesystem/filesystem:1:11: error: expected unqualified-id
filesystem/checkpath.cpp
^
3 errors generated.
g++ filesystem/createfiles.cpp -std=c++2a -Wall
Undefined symbols for architecture x86_64:
"std::filesystem::__cxx11::recursive_directory_iterator::operator*() const", referenced from:
_main in ccwnfBsO.o
"std::filesystem::__cxx11::path::has_filename() const", referenced from:
std::filesystem::__cxx11::path::operator/=(std::filesystem::__cxx11::path const&) in ccwnfBsO.o
"std::filesystem::__cxx11::path::has_root_directory() const", referenced from:
std::filesystem::__cxx11::path::is_absolute() const in ccwnfBsO.o
"std::filesystem::create_symlink(std::filesystem::__cxx11::path const&, std::filesystem::__cxx11::path const&)", referenced from:
_main in ccwnfBsO.o
"std::filesystem::create_directory(std::filesystem::__cxx11::path const&)", referenced from:
_main in ccwnfBsO.o
"std::filesystem::__cxx11::recursive_directory_iterator::recursive_directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options, std::error_code*)", referenced from:
std::filesystem::__cxx11::recursive_directory_iterator::recursive_directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options) in ccwnfBsO.o
"std::filesystem::__cxx11::recursive_directory_iterator::~recursive_directory_iterator()", referenced from:
_main in ccwnfBsO.o
"std::filesystem::__cxx11::recursive_directory_iterator::operator++()", referenced from:
_main in ccwnfBsO.o
"std::filesystem::__cxx11::path::_M_split_cmpts()", referenced from:
std::filesystem::__cxx11::path::operator/=(std::filesystem::__cxx11::path const&) in ccwnfBsO.o
std::filesystem::__cxx11::path::_M_append(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) in ccwnfBsO.o
std::filesystem::__cxx11::path::path<char [5], std::filesystem::__cxx11::path>(char const (&) [5], std::filesystem::__cxx11::path::format) in ccwnfBsO.o
std::filesystem::__cxx11::path::path<char [12], std::filesystem::__cxx11::path>(char const (&) [12], std::filesystem::__cxx11::path::format) in ccwnfBsO.o
std::filesystem::__cxx11::path::path<char [2], std::filesystem::__cxx11::path>(char const (&) [2], std::filesystem::__cxx11::path::format) in ccwnfBsO.o
"typeinfo for std::filesystem::__cxx11::filesystem_error", referenced from:
anon in ccwnfBsO.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
###switchinit
clang++ filesystem/switchinit.cpp -std=c++2a -Wall
filesystem/switchinit.cpp:4:10: error: 'filesystem' file not found with <angled> include; use "quotes" instead
#include <filesystem>
^~~~~~~~~~~~
"filesystem"
In file included from filesystem/switchinit.cpp:4:
filesystem/filesystem:1:1: error: unknown type name 'filesystem'
filesystem/checkpath.cpp
^
filesystem/filesystem:1:11: error: expected unqualified-id
filesystem/checkpath.cpp
^
filesystem/switchinit.cpp:6:26: error: expected namespace name
using namespace std::experimental;
~~~~~^
filesystem/switchinit.cpp:11:24: error: expected namespace name
using namespace std::filesystem;
~~~~~^
filesystem/switchinit.cpp:13:11: error: unknown type name 'path'
switch (path p(name); status(p).type()) {
^
6 errors generated.
g++ filesystem/switchinit.cpp -std=c++2a -Wall
filesystem/switchinit.cpp:6:26: error: 'experimental' is not a namespace-name
using namespace std::experimental;
^~~~~~~~~~~~
filesystem/switchinit.cpp:6:38: error: expected namespace-name before ';' token
using namespace std::experimental;
^
##検討事項(agenda)
1)コンパイルエラーをなくす修正方法
2)役に立つまたは意味のあるその他の出力
#台本(script)
毎回コンパイル条件を変えてコンパイルするのに、一気にコンパイルする方法
#!/bin/bash
while read line
do
echo "clang++ $line -std=c++2a -Wall"
clang++ $line -std=c++2a -Wall
if [ -e a.out ]; then
./a.out
rm a.out
fi
echo "g++ $line -std=c++2a -Wall"
g++ $line -std=c++2a -Wall
if [ -e a.out ]; then
./a.out
rm a.out
fi
done < ./$1
#!/bin/bash
while read line
do
ls ./$line/*.cpp > ./$line/$line
./cga.sh ./$line/$line > $line.log.txt &> $line.log.txt
done < ./$1
#参考資料(reference)
###プログラミング言語教育のXYZ
https://qiita.com/kaizen_nagoya/items/1950c5810fb5c0b07be4
プログラミング言語教育のXYZ(youtube)
https://www.youtube.com/watch?v=He1_tg4px-w&t=486s
###Autosar Guidelines C++14
Autosar Guidelines C++14 example code compile list(1-169)
https://qiita.com/kaizen_nagoya/items/8ccbf6675c3494d57a76
###C++N4741 2018
Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4741.pdf
C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
https://qiita.com/kaizen_nagoya/items/3294c014044550896010
###C++N4606 2016
Working Draft, Standard for Programming Language C++
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4606.pdf
C++N4606, 2016符号断片編纂一覧(example code compile list)
Working Draft 2016, ISO/IEC 14882(1)
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/
### CEDD(Compile Error Driven Design)
初めての CEDD(Compile Error Driven Design) 8回直してコンパイル。
https://qiita.com/kaizen_nagoya/items/9494236aa1753f3fd1e1
コンパイルエラーを記録するとよい理由7つ
https://qiita.com/kaizen_nagoya/items/85c0e92b206883140e89
docker gnu(gcc/g++) and llvm(clang/clang++)
https://qiita.com/drafts/059874ea39c4de64c0f7
[C][C++]の国際規格案の例題をコンパイルするときの課題7つ。
https://qiita.com/kaizen_nagoya/items/5f4b155030259497c4de
C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standardのコード断片をコンパイルするためにしていること
https://qiita.com/kaizen_nagoya/items/a8d7ee2f2e29e76c19c1
コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da
Clang/Clang++(LLVM) gcc/g++(GNU) コンパイラ警告等比較
https://qiita.com/kaizen_nagoya/items/9a82b958cc3aeef0403f
C++2003とC++2017でコンパイルエラーになるならない事例集
https://qiita.com/kaizen_nagoya/items/a13ea3823441c430edff
Qiitaに投稿するCのStyle例(暫定)
https://qiita.com/kaizen_nagoya/items/946df1528a6a1ef2bc0d
cpprefjpのdecltypeをコンパイル試験
https://qiita.com/kaizen_nagoya/items/090909af702f0d5d8a67
MISRA C++ 5-0-16
https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74
C++ Templates Part1 BASICS Chapter 3. Class Templates 3.2 Use of Class Template Stack stack1test.cpp
https://qiita.com/kaizen_nagoya/items/cd5fc49106fad5a4e9ed
ISO/IEC TS 17961:2013 C Secure Coding Rules(1) All list(to be confirmed)
https://qiita.com/kaizen_nagoya/items/54e056195c4f11b850a1
C言語(C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a
C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9
'wchar.h' file not found で困った clang++ macOS
https://qiita.com/kaizen_nagoya/items/de15cd46d657517fac11
Open POSIX Test Suiteの使い方を調べはじめました
https://qiita.com/kaizen_nagoya/items/644d5e407f5faf96e6dc
MISRA-C 2012 Referenceに掲載している文献の入手可能性を確認
https://qiita.com/kaizen_nagoya/items/96dc8b125e462d5575bb
どうやって MISRA Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00
MISRA C まとめ #include
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9
「C++完全理解ガイド」の同意できること上位10
https://qiita.com/kaizen_nagoya/items/aa5744e0c4a8618c7671
文献履歴(document history)
ver. 0.10 初稿 20180616
ver. 0.11 一覧追記 20180617
最後までおよみいただきありがとうございました。
いいね 💚、フォローをお願いします。
Thank you very much for reading to the last sentence.
Please press the like icon 💚 and follow me for your happy life.