はじめに(Introduction)
N4910 Working Draft, Standard for Programming Language C++
n4910は、ISO/IEC JTC1 SC22 WG21の作業原案(Working Draft)です。
公式のISO/IEC 14882原本ではありません。
ISO/IEC JTC1 SC22 WG21では、可能な限り作業文書を公開し、幅広い意見を求めています。
一連の記事はコード断片をコンパイルできる形にする方法を検討してコンパイル、リンク、実行して、規格案の原文と処理系(g++, Clang++)との違いを確認し、技術内容を検討し、ISO/IEC JTC1 SC22 WG21にフィードバックするために用います。
また、CERT C++, MISRA C++等のコーディング標準のコード断片をコンパイルする際の参考にさせていただこうと考えています。CERT C++, MISRA C++が標準化の動きとの時間的なずれがあれば確認できれば幸いです。また、boostライブラリとの関連、Linux OS, TOPPERSカーネル、g++(GCC), clang++(LLVM)との関係も調査中です。
何か、抜け漏れ、耳より情報がありましたらおしらせくださると幸いです。
<この項は書きかけです。順次追記します。>
背景(back ground)
C/C++でコンパイルエラーが出ると、途方にくれることがしばしばあります。
何回かに1回は、該当するエラーが検索できます。
ただ、条件が違っていて、そこでの修正方法では目的を達成しないこともしばしばです。いろいろな条件のコンパイルエラーとその対応方法について、広く記録することによって、いつか同じエラーに遭遇した時にやくに立つことを目指しています。
この半年の間で、三度、自分のネットでの記録に助けられたことがあります。
また過去に解決できなかった記録を10種類以上、最近になって解決できたことがあります。それは、主に次の3つの情報に基づいています。
https://stackoverflow.com
https://cpprefjp.github.io
http://ja.cppreference.com/
また
https://researchmap.jp/joub9b3my-1797580/#_1797580
に記載したサイトのお世話になっています。
作業方針(sequence)
Clang++では-std=c++03, C++2bの2種類
g++では-std=c++03, c++2bの2種類
でコンパイルし、
1)コンパイルエラーを収集する。
2)コンパイルエラーをなくす方法を検討する。
コンパイルエラーになる例を示すだけが目的のコードは、コンパイルエラーをなくすのではなく、コンパイルエラーの種類を収集するだけにする。
文法を示すのが目的のコード場合に、コンパイルエラーをなくすのに手間がかかる場合は、順次作業します。
3)リンクエラーをなくす方法を検討する。
文法を示すのが目的のコード場合に、リンクエラーをなくすのに手間がかかる場合は、順次作業します。
4)意味のある出力を作る。
コンパイル、リンクが通っても、意味のある出力を示そうとすると、コンパイル・リンクエラーが出て収拾できそうにない場合がある。順次作業します。
1)だけのものから4)まで進んだものと色々ある状態です。一歩でも前に進むご助言をお待ちしています。「検討事項」の欄に現状を記録するようにしています。
C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
C++N4741, 2018 Standard Working Draft on ISO/IEC 14882 sample code compile list
C++N4606, 2016符号断片編纂一覧(example code compile list)
C++N4606, 2016 Working Draft 2016, ISO/IEC 14882, C++ standard(1) Example code compile list
https://qiita.com/kaizen_nagoya/items/df5d62c35bd6ed1c3d43/
C++N3242, 2011 sample code compile list on clang++ and g++
編纂器(Compiler)
clang++ --version
Debian clang version 14.0.5-++20220610033153+c12386ae247c-1~exp1~20220610153237.151
Target: x86_64-pc-linux-gnu, Thread model: posix, InstalledDir: /usr/bin
g++- --version
g++ (GCC) 12.1.0 Copyright (C) 2022 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.
17.4.2 Header synopsis [cstdint.syn] C++N4910:2022 (279) p511.cpp
算譜(source code)
// C++N4910 Committee Draft, Standard for Programming Language C++
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4910.pdf
const char * n4910 = "17.4.2 Header <cstdint> synopsis [cstdint.syn] C++N4910:2022 (279) p511.cpp";
// Debian clang version 14.0.5-++20220610033153+c12386ae247c-
// g++ (GCC) 12.1.0 Copyright (C) 2022 Free Software Foundation, Inc.
// Edited by Dr. OGAWA Kiyoshi. Compile procedure and results record.
// C++N4910:2022 Standard Working Draft on ISO/IEC 14882(0) sample code compile list
// https://qiita.com/kaizen_nagoya/items/fc957ddddd402004bb91
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <coroutine>
#include <vector>
#include <complex>
#include <map>
#include <atomic>
#include <unordered_map>
#include <typeinfo>
#include <cstdint>
using namespace std;
#define signed_integer_type int
#define unsigned_integer_type unsigned int
#define see_below int
// Example 1
namespace std {
using int8_t = signed_integer_type ;
using int16_t = signed_integer_type ;
using int32_t = signed_integer_type ;
using int64_t = signed_integer_type ;
using intN_t = see_below;
using int_fast8_t = signed_integer_type ;
using int_fast16_t = signed_integer_type ;
using int_fast32_t = signed_integer_type ;
using int_fast64_t = signed_integer_type ;
using int_fastN_t = see_below;
using int_least8_t = signed_integer_type ;
using int_least16_t = signed_integer_type ;
using int_least32_t = signed_integer_type ;
using int_least64_t = signed_integer_type ;
using int_leastN_t = see_below;
using intmax_t = signed_integer_type ;
using intptr_t = signed_integer_type ;
using uint8_t = unsigned_integer_type;
using uint16_t = unsigned_integer_type;
using uint32_t = unsigned_integer_type;
using uint64_t = unsigned_integer_type;
using uintN_t = see_below;
using uint_fast8_tstN_t = unsigned_integer_type;
using uint_fast16_t = unsigned_integer_type;
using uint_fast32_t = unsigned_integer_type;
using uint_fast64_t = unsigned_integer_type;
using uint_fastN_t = see_below;
using uint_least8_t = unsigned_integer_type;
using uint_least16_t = unsigned_integer_type;
using uint_least32_t = unsigned_integer_type;
using uint_least64_t = unsigned_integer_type;
using uint_leastN_t = see_below;
}
#define INTN_MIN see_below
#define INTN_MAX see_below
#define UINTN_MAX see_below
#define INT_FASTN_MIN see_below
#define INT_FASTN_MAX see_below
#define UINT_FASTN_MAX see_below
#define INT_LEASTN_MIN see_below
#define INT_LEASTN_MAX see_below
#define UINT_LEASTN_MAX see_below
#define INTMAX_MIN see_below
#define INTMAX_MAX see_below
#define UINTMAX_MAX see_below
#define INTPTR_MIN see_below
#define INTPTR_MAX see_below
#define UINTPTR_MAX see_below
#define PTRDIFF_MIN see_below
#define PTRDIFF_MAX see_below
#define SIZE_MAX see_below
#define SIG_ATOMIC_MIN see_below
#define SIG_ATOMIC_MAX see_below
#define WCHAR_MIN see_below
#define WCHAR_MAX see_below
#define WINT_MIN see_below
#define WINT_MAX see_below
#define INTN_C(value) see_below
#define UINTN_C(value) see_below
#define INTMAX_C(value) see below
#define UINTMAX_C(value) see below
int main() {
cout << n4910 << endl;
return EXIT_SUCCESS;
}
Script
#!/bin/sh
rm $1l
rm $1g
echo "$ clang++ $1.cpp -std=03 -o $1l -I. -Wall"
clang++ $1.cpp -std=c++03 -o $1l -I. -Wall
if [ -e $1l ]; then
./$1l
fi
rm $1l
echo "$ clang++ $1.cpp -std=2b -o $1l -I. -Wall"
clang++ $1.cpp -std=c++2b -o $1l -I. -Wall
if [ -e $1l ]; then
./$1l
fi
echo "\r"
echo "$ g++ $1.cpp -std=03 -o $1g -I. -Wall"
g++ $1.cpp -std=c++03 -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
rm $1g
echo "\r"
echo "$ g++ $1.cpp -std=2b -o $1g -I. -Wall"
g++ $1.cpp -std=c++2b -o $1g -I. -Wall
if [ -e $1g ]; then
./$1g
fi
編纂・実行結果(compile and go)
# ./clgc.sh p511
$ clang++ p511.cpp -std=c++03 -o p511l -I. -Wall
In file included from p511.cpp:19:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/atomic:38:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
p511.cpp:31:16: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int8_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:32:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int16_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:33:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int32_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:34:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int64_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:35:16: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using intN_t = see_below;
^
p511.cpp:28:19: note: expanded from macro 'see_below'
#define see_below int
^
p511.cpp:36:21: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_fast8_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:37:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_fast16_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:38:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_fast32_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:39:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_fast64_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:40:21: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_fastN_t = see_below;
^
p511.cpp:28:19: note: expanded from macro 'see_below'
#define see_below int
^
p511.cpp:41:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_least8_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:42:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_least16_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:43:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_least32_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:44:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_least64_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:45:22: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using int_leastN_t = see_below;
^
p511.cpp:28:19: note: expanded from macro 'see_below'
#define see_below int
^
p511.cpp:46:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using intmax_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:47:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using intptr_t = signed_integer_type ;
^
p511.cpp:26:29: note: expanded from macro 'signed_integer_type'
#define signed_integer_type int
^
p511.cpp:48:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint8_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:49:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint16_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:50:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint32_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:51:18: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint64_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:52:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uintN_t = see_below;
^
p511.cpp:28:19: note: expanded from macro 'see_below'
#define see_below int
^
p511.cpp:53:27: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_fast8_tstN_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:54:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_fast16_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:55:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_fast32_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:56:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_fast64_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:57:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_fastN_t = see_below;
^
p511.cpp:28:19: note: expanded from macro 'see_below'
#define see_below int
^
p511.cpp:58:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_least8_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:59:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_least16_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:60:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_least32_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:61:24: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_least64_t = unsigned_integer_type;
^
p511.cpp:27:31: note: expanded from macro 'unsigned_integer_type'
#define unsigned_integer_type unsigned int
^
p511.cpp:62:23: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using uint_leastN_t = see_below;
^
p511.cpp:28:19: note: expanded from macro 'see_below'
#define see_below int
^
p511.cpp:84:9: warning: 'WCHAR_MIN' macro redefined [-Wmacro-redefined]
#define WCHAR_MIN see_below
^
/usr/include/wchar.h:59:10: note: previous definition is here
# define WCHAR_MIN __WCHAR_MIN
^
p511.cpp:85:9: warning: 'WCHAR_MAX' macro redefined [-Wmacro-redefined]
#define WCHAR_MAX see_below
^
/usr/include/wchar.h:60:10: note: previous definition is here
# define WCHAR_MAX __WCHAR_MAX
^
34 warnings and 1 error generated.
rm: cannot remove 'p511l': No such file or directory
$ clang++ p511.cpp -std=c++2b -o p511l -I. -Wall
p511.cpp:31:7: error: typedef redefinition with different types ('int' vs '__int8_t' (aka 'signed char'))
using int8_t = signed_integer_type ;
^
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:24:18: note: previous definition is here
typedef __int8_t int8_t;
^
p511.cpp:32:7: error: typedef redefinition with different types ('int' vs '__int16_t' (aka 'short'))
using int16_t = signed_integer_type ;
^
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:25:19: note: previous definition is here
typedef __int16_t int16_t;
^
p511.cpp:34:7: error: typedef redefinition with different types ('int' vs '__int64_t' (aka 'long'))
using int64_t = signed_integer_type ;
^
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous definition is here
typedef __int64_t int64_t;
^
p511.cpp:36:7: error: typedef redefinition with different types ('int' vs 'signed char')
using int_fast8_t = signed_integer_type ;
^
/usr/include/stdint.h:58:22: note: previous definition is here
typedef signed char int_fast8_t;
^
p511.cpp:37:7: error: typedef redefinition with different types ('int' vs 'long')
using int_fast16_t = signed_integer_type ;
^
/usr/include/stdint.h:60:19: note: previous definition is here
typedef long int int_fast16_t;
^
p511.cpp:38:7: error: typedef redefinition with different types ('int' vs 'long')
using int_fast32_t = signed_integer_type ;
^
/usr/include/stdint.h:61:19: note: previous definition is here
typedef long int int_fast32_t;
^
p511.cpp:39:7: error: typedef redefinition with different types ('int' vs 'long')
using int_fast64_t = signed_integer_type ;
^
/usr/include/stdint.h:62:19: note: previous definition is here
typedef long int int_fast64_t;
^
p511.cpp:41:7: error: typedef redefinition with different types ('int' vs '__int_least8_t' (aka 'signed char'))
using int_least8_t = signed_integer_type ;
^
/usr/include/stdint.h:43:24: note: previous definition is here
typedef __int_least8_t int_least8_t;
^
p511.cpp:42:7: error: typedef redefinition with different types ('int' vs '__int_least16_t' (aka 'short'))
using int_least16_t = signed_integer_type ;
^
/usr/include/stdint.h:44:25: note: previous definition is here
typedef __int_least16_t int_least16_t;
^
p511.cpp:44:7: error: typedef redefinition with different types ('int' vs '__int_least64_t' (aka 'long'))
using int_least64_t = signed_integer_type ;
^
/usr/include/stdint.h:46:25: note: previous definition is here
typedef __int_least64_t int_least64_t;
^
p511.cpp:46:7: error: typedef redefinition with different types ('int' vs '__intmax_t' (aka 'long'))
using intmax_t = signed_integer_type ;
^
/usr/include/stdint.h:101:21: note: previous definition is here
typedef __intmax_t intmax_t;
^
p511.cpp:47:7: error: typedef redefinition with different types ('int' vs 'long')
using intptr_t = signed_integer_type ;
^
/usr/include/stdint.h:87:19: note: previous definition is here
typedef long int intptr_t;
^
p511.cpp:48:7: error: typedef redefinition with different types ('unsigned int' vs '__uint8_t' (aka 'unsigned char'))
using uint8_t = unsigned_integer_type;
^
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:24:19: note: previous definition is here
typedef __uint8_t uint8_t;
^
p511.cpp:49:7: error: typedef redefinition with different types ('unsigned int' vs '__uint16_t' (aka 'unsigned short'))
using uint16_t = unsigned_integer_type;
^
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:25:20: note: previous definition is here
typedef __uint16_t uint16_t;
^
p511.cpp:51:7: error: typedef redefinition with different types ('unsigned int' vs '__uint64_t' (aka 'unsigned long'))
using uint64_t = unsigned_integer_type;
^
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:27:20: note: previous definition is here
typedef __uint64_t uint64_t;
^
p511.cpp:54:7: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long')
using uint_fast16_t = unsigned_integer_type;
^
/usr/include/stdint.h:73:27: note: previous definition is here
typedef unsigned long int uint_fast16_t;
^
p511.cpp:55:7: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long')
using uint_fast32_t = unsigned_integer_type;
^
/usr/include/stdint.h:74:27: note: previous definition is here
typedef unsigned long int uint_fast32_t;
^
p511.cpp:56:7: error: typedef redefinition with different types ('unsigned int' vs 'unsigned long')
using uint_fast64_t = unsigned_integer_type;
^
/usr/include/stdint.h:75:27: note: previous definition is here
typedef unsigned long int uint_fast64_t;
^
p511.cpp:58:7: error: typedef redefinition with different types ('unsigned int' vs '__uint_least8_t' (aka 'unsigned char'))
using uint_least8_t = unsigned_integer_type;
^
/usr/include/stdint.h:49:25: note: previous definition is here
typedef __uint_least8_t uint_least8_t;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
$ g++ p511.cpp -std=c++03 -o p511g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from p511.cpp:19:
/usr/local/include/c++/12.1.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
32 | #error This file requires compiler and library support \
| ^~~~~
p511.cpp:84: warning: "WCHAR_MIN" redefined
84 | #define WCHAR_MIN see_below
|
In file included from /usr/local/include/c++/12.1.0/cwchar:44,
from /usr/local/include/c++/12.1.0/bits/postypes.h:40,
from /usr/local/include/c++/12.1.0/iosfwd:40,
from /usr/local/include/c++/12.1.0/ios:38,
from /usr/local/include/c++/12.1.0/ostream:38,
from /usr/local/include/c++/12.1.0/iostream:39,
from p511.cpp:10:
/usr/include/wchar.h:59: note: this is the location of the previous definition
59 | # define WCHAR_MIN __WCHAR_MIN
|
p511.cpp:85: warning: "WCHAR_MAX" redefined
85 | #define WCHAR_MAX see_below
|
/usr/include/wchar.h:60: note: this is the location of the previous definition
60 | # define WCHAR_MAX __WCHAR_MAX
|
p511.cpp:31:7: error: expected nested-name-specifier before 'int8_t'
31 | using int8_t = signed_integer_type ;
| ^~~~~~
p511.cpp:32:7: error: expected nested-name-specifier before 'int16_t'
32 | using int16_t = signed_integer_type ;
| ^~~~~~~
p511.cpp:33:7: error: expected nested-name-specifier before 'int32_t'
33 | using int32_t = signed_integer_type ;
| ^~~~~~~
p511.cpp:34:7: error: expected nested-name-specifier before 'int64_t'
34 | using int64_t = signed_integer_type ;
| ^~~~~~~
p511.cpp:35:7: error: expected nested-name-specifier before 'intN_t'
35 | using intN_t = see_below;
| ^~~~~~
p511.cpp:36:7: error: expected nested-name-specifier before 'int_fast8_t'
36 | using int_fast8_t = signed_integer_type ;
| ^~~~~~~~~~~
p511.cpp:37:7: error: expected nested-name-specifier before 'int_fast16_t'
37 | using int_fast16_t = signed_integer_type ;
| ^~~~~~~~~~~~
p511.cpp:38:7: error: expected nested-name-specifier before 'int_fast32_t'
38 | using int_fast32_t = signed_integer_type ;
| ^~~~~~~~~~~~
p511.cpp:39:7: error: expected nested-name-specifier before 'int_fast64_t'
39 | using int_fast64_t = signed_integer_type ;
| ^~~~~~~~~~~~
p511.cpp:40:7: error: expected nested-name-specifier before 'int_fastN_t'
40 | using int_fastN_t = see_below;
| ^~~~~~~~~~~
p511.cpp:41:7: error: expected nested-name-specifier before 'int_least8_t'
41 | using int_least8_t = signed_integer_type ;
| ^~~~~~~~~~~~
p511.cpp:42:7: error: expected nested-name-specifier before 'int_least16_t'
42 | using int_least16_t = signed_integer_type ;
| ^~~~~~~~~~~~~
p511.cpp:43:7: error: expected nested-name-specifier before 'int_least32_t'
43 | using int_least32_t = signed_integer_type ;
| ^~~~~~~~~~~~~
p511.cpp:44:7: error: expected nested-name-specifier before 'int_least64_t'
44 | using int_least64_t = signed_integer_type ;
| ^~~~~~~~~~~~~
p511.cpp:45:7: error: expected nested-name-specifier before 'int_leastN_t'
45 | using int_leastN_t = see_below;
| ^~~~~~~~~~~~
p511.cpp:46:7: error: expected nested-name-specifier before 'intmax_t'
46 | using intmax_t = signed_integer_type ;
| ^~~~~~~~
p511.cpp:47:7: error: expected nested-name-specifier before 'intptr_t'
47 | using intptr_t = signed_integer_type ;
| ^~~~~~~~
p511.cpp:48:7: error: expected nested-name-specifier before 'uint8_t'
48 | using uint8_t = unsigned_integer_type;
| ^~~~~~~
p511.cpp:49:7: error: expected nested-name-specifier before 'uint16_t'
49 | using uint16_t = unsigned_integer_type;
| ^~~~~~~~
p511.cpp:50:7: error: expected nested-name-specifier before 'uint32_t'
50 | using uint32_t = unsigned_integer_type;
| ^~~~~~~~
p511.cpp:51:7: error: expected nested-name-specifier before 'uint64_t'
51 | using uint64_t = unsigned_integer_type;
| ^~~~~~~~
p511.cpp:52:7: error: expected nested-name-specifier before 'uintN_t'
52 | using uintN_t = see_below;
| ^~~~~~~
p511.cpp:53:7: error: expected nested-name-specifier before 'uint_fast8_tstN_t'
53 | using uint_fast8_tstN_t = unsigned_integer_type;
| ^~~~~~~~~~~~~~~~~
p511.cpp:54:7: error: expected nested-name-specifier before 'uint_fast16_t'
54 | using uint_fast16_t = unsigned_integer_type;
| ^~~~~~~~~~~~~
p511.cpp:55:7: error: expected nested-name-specifier before 'uint_fast32_t'
55 | using uint_fast32_t = unsigned_integer_type;
| ^~~~~~~~~~~~~
p511.cpp:56:7: error: expected nested-name-specifier before 'uint_fast64_t'
56 | using uint_fast64_t = unsigned_integer_type;
| ^~~~~~~~~~~~~
p511.cpp:57:7: error: expected nested-name-specifier before 'uint_fastN_t'
57 | using uint_fastN_t = see_below;
| ^~~~~~~~~~~~
p511.cpp:58:7: error: expected nested-name-specifier before 'uint_least8_t'
58 | using uint_least8_t = unsigned_integer_type;
| ^~~~~~~~~~~~~
p511.cpp:59:7: error: expected nested-name-specifier before 'uint_least16_t'
59 | using uint_least16_t = unsigned_integer_type;
| ^~~~~~~~~~~~~~
p511.cpp:60:7: error: expected nested-name-specifier before 'uint_least32_t'
60 | using uint_least32_t = unsigned_integer_type;
| ^~~~~~~~~~~~~~
p511.cpp:61:7: error: expected nested-name-specifier before 'uint_least64_t'
61 | using uint_least64_t = unsigned_integer_type;
| ^~~~~~~~~~~~~~
p511.cpp:62:7: error: expected nested-name-specifier before 'uint_leastN_t'
62 | using uint_leastN_t = see_below;
| ^~~~~~~~~~~~~
rm: cannot remove 'p511g': No such file or directory
$ g++ p511.cpp -std=c++2b -o p511g -I. -Wall
p511.cpp:73: warning: "INTMAX_MIN" redefined
73 | #define INTMAX_MIN see_below
|
In file included from /usr/local/lib/gcc/x86_64-linux-gnu/12.1.0/include/stdint.h:9,
from /usr/local/include/c++/12.1.0/cstdint:41,
from /usr/local/include/c++/12.1.0/bits/char_traits.h:731,
from /usr/local/include/c++/12.1.0/ios:40,
from /usr/local/include/c++/12.1.0/ostream:38,
from /usr/local/include/c++/12.1.0/iostream:39,
from p511.cpp:10:
/usr/include/stdint.h:197: note: this is the location of the previous definition
197 | # define INTMAX_MIN (-__INT64_C(9223372036854775807)-1)
|
p511.cpp:74: warning: "INTMAX_MAX" redefined
74 | #define INTMAX_MAX see_below
|
/usr/include/stdint.h:199: note: this is the location of the previous definition
199 | # define INTMAX_MAX (__INT64_C(9223372036854775807))
|
p511.cpp:75: warning: "UINTMAX_MAX" redefined
75 | #define UINTMAX_MAX see_below
|
/usr/include/stdint.h:202: note: this is the location of the previous definition
202 | # define UINTMAX_MAX (__UINT64_C(18446744073709551615))
|
p511.cpp:76: warning: "INTPTR_MIN" redefined
76 | #define INTPTR_MIN see_below
|
/usr/include/stdint.h:186: note: this is the location of the previous definition
186 | # define INTPTR_MIN (-9223372036854775807L-1)
|
p511.cpp:77: warning: "INTPTR_MAX" redefined
77 | #define INTPTR_MAX see_below
|
/usr/include/stdint.h:187: note: this is the location of the previous definition
187 | # define INTPTR_MAX (9223372036854775807L)
|
p511.cpp:78: warning: "UINTPTR_MAX" redefined
78 | #define UINTPTR_MAX see_below
|
/usr/include/stdint.h:188: note: this is the location of the previous definition
188 | # define UINTPTR_MAX (18446744073709551615UL)
|
p511.cpp:79: warning: "PTRDIFF_MIN" redefined
79 | #define PTRDIFF_MIN see_below
|
/usr/include/stdint.h:209: note: this is the location of the previous definition
209 | # define PTRDIFF_MIN (-9223372036854775807L-1)
|
p511.cpp:80: warning: "PTRDIFF_MAX" redefined
80 | #define PTRDIFF_MAX see_below
|
/usr/include/stdint.h:210: note: this is the location of the previous definition
210 | # define PTRDIFF_MAX (9223372036854775807L)
|
p511.cpp:81: warning: "SIZE_MAX" redefined
81 | #define SIZE_MAX see_below
|
/usr/include/stdint.h:227: note: this is the location of the previous definition
227 | # define SIZE_MAX (18446744073709551615UL)
|
p511.cpp:82: warning: "SIG_ATOMIC_MIN" redefined
82 | #define SIG_ATOMIC_MIN see_below
|
/usr/include/stdint.h:222: note: this is the location of the previous definition
222 | # define SIG_ATOMIC_MIN (-2147483647-1)
|
p511.cpp:83: warning: "SIG_ATOMIC_MAX" redefined
83 | #define SIG_ATOMIC_MAX see_below
|
/usr/include/stdint.h:223: note: this is the location of the previous definition
223 | # define SIG_ATOMIC_MAX (2147483647)
|
p511.cpp:84: warning: "WCHAR_MIN" redefined
84 | #define WCHAR_MIN see_below
|
In file included from /usr/local/include/c++/12.1.0/cwchar:44,
from /usr/local/include/c++/12.1.0/bits/postypes.h:40,
from /usr/local/include/c++/12.1.0/iosfwd:40,
from /usr/local/include/c++/12.1.0/ios:38:
/usr/include/wchar.h:59: note: this is the location of the previous definition
59 | # define WCHAR_MIN __WCHAR_MIN
|
p511.cpp:85: warning: "WCHAR_MAX" redefined
85 | #define WCHAR_MAX see_below
|
/usr/include/wchar.h:60: note: this is the location of the previous definition
60 | # define WCHAR_MAX __WCHAR_MAX
|
p511.cpp:86: warning: "WINT_MIN" redefined
86 | #define WINT_MIN see_below
|
/usr/include/stdint.h:244: note: this is the location of the previous definition
244 | # define WINT_MIN (0u)
|
p511.cpp:87: warning: "WINT_MAX" redefined
87 | #define WINT_MAX see_below
|
/usr/include/stdint.h:245: note: this is the location of the previous definition
245 | # define WINT_MAX (4294967295u)
|
p511.cpp:90: warning: "INTMAX_C" redefined
90 | #define INTMAX_C(value) see below
|
/usr/include/stdint.h:269: note: this is the location of the previous definition
269 | # define INTMAX_C(c) c ## L
|
p511.cpp:91: warning: "UINTMAX_C" redefined
91 | #define UINTMAX_C(value) see below
|
/usr/include/stdint.h:270: note: this is the location of the previous definition
270 | # define UINTMAX_C(c) c ## UL
|
p511.cpp:31:36: error: 'using int8_t = int' conflicts with a previous declaration
31 | using int8_t = signed_integer_type ;
| ^
In file included from /usr/include/stdint.h:34:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:24:18: note: previous declaration 'typedef __int8_t int8_t'
24 | typedef __int8_t int8_t;
| ^~~~~~
p511.cpp:32:37: error: 'using int16_t = int' conflicts with a previous declaration
32 | using int16_t = signed_integer_type ;
| ^
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:25:19: note: previous declaration 'typedef __int16_t int16_t'
25 | typedef __int16_t int16_t;
| ^~~~~~~
p511.cpp:34:37: error: 'using int64_t = int' conflicts with a previous declaration
34 | using int64_t = signed_integer_type ;
| ^
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous declaration 'typedef __int64_t int64_t'
27 | typedef __int64_t int64_t;
| ^~~~~~~
p511.cpp:36:41: error: 'using int_fast8_t = int' conflicts with a previous declaration
36 | using int_fast8_t = signed_integer_type ;
| ^
/usr/include/stdint.h:58:33: note: previous declaration 'typedef signed char int_fast8_t'
58 | typedef signed char int_fast8_t;
| ^~~~~~~~~~~
p511.cpp:37:42: error: 'using int_fast16_t = int' conflicts with a previous declaration
37 | using int_fast16_t = signed_integer_type ;
| ^
/usr/include/stdint.h:60:33: note: previous declaration 'typedef long int int_fast16_t'
60 | typedef long int int_fast16_t;
| ^~~~~~~~~~~~
p511.cpp:38:42: error: 'using int_fast32_t = int' conflicts with a previous declaration
38 | using int_fast32_t = signed_integer_type ;
| ^
/usr/include/stdint.h:61:33: note: previous declaration 'typedef long int int_fast32_t'
61 | typedef long int int_fast32_t;
| ^~~~~~~~~~~~
p511.cpp:39:42: error: 'using int_fast64_t = int' conflicts with a previous declaration
39 | using int_fast64_t = signed_integer_type ;
| ^
/usr/include/stdint.h:62:33: note: previous declaration 'typedef long int int_fast64_t'
62 | typedef long int int_fast64_t;
| ^~~~~~~~~~~~
p511.cpp:41:42: error: 'using int_least8_t = int' conflicts with a previous declaration
41 | using int_least8_t = signed_integer_type ;
| ^
/usr/include/stdint.h:43:24: note: previous declaration 'typedef __int_least8_t int_least8_t'
43 | typedef __int_least8_t int_least8_t;
| ^~~~~~~~~~~~
p511.cpp:42:43: error: 'using int_least16_t = int' conflicts with a previous declaration
42 | using int_least16_t = signed_integer_type ;
| ^
/usr/include/stdint.h:44:25: note: previous declaration 'typedef __int_least16_t int_least16_t'
44 | typedef __int_least16_t int_least16_t;
| ^~~~~~~~~~~~~
p511.cpp:44:43: error: 'using int_least64_t = int' conflicts with a previous declaration
44 | using int_least64_t = signed_integer_type ;
| ^
/usr/include/stdint.h:46:25: note: previous declaration 'typedef __int_least64_t int_least64_t'
46 | typedef __int_least64_t int_least64_t;
| ^~~~~~~~~~~~~
p511.cpp:46:38: error: 'using intmax_t = int' conflicts with a previous declaration
46 | using intmax_t = signed_integer_type ;
| ^
/usr/include/stdint.h:101:33: note: previous declaration 'typedef __intmax_t intmax_t'
101 | typedef __intmax_t intmax_t;
| ^~~~~~~~
p511.cpp:47:38: error: 'using intptr_t = int' conflicts with a previous declaration
47 | using intptr_t = signed_integer_type ;
| ^
/usr/include/stdint.h:87:33: note: previous declaration 'typedef long int intptr_t'
87 | typedef long int intptr_t;
| ^~~~~~~~
p511.cpp:48:38: error: 'using uint8_t = unsigned int' conflicts with a previous declaration
48 | using uint8_t = unsigned_integer_type;
| ^
In file included from /usr/include/stdint.h:37:
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:24:19: note: previous declaration 'typedef __uint8_t uint8_t'
24 | typedef __uint8_t uint8_t;
| ^~~~~~~
p511.cpp:49:39: error: 'using uint16_t = unsigned int' conflicts with a previous declaration
49 | using uint16_t = unsigned_integer_type;
| ^
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:25:20: note: previous declaration 'typedef __uint16_t uint16_t'
25 | typedef __uint16_t uint16_t;
| ^~~~~~~~
p511.cpp:51:39: error: 'using uint64_t = unsigned int' conflicts with a previous declaration
51 | using uint64_t = unsigned_integer_type;
| ^
/usr/include/x86_64-linux-gnu/bits/stdint-uintn.h:27:20: note: previous declaration 'typedef __uint64_t uint64_t'
27 | typedef __uint64_t uint64_t;
| ^~~~~~~~
p511.cpp:54:44: error: 'using uint_fast16_t = unsigned int' conflicts with a previous declaration
54 | using uint_fast16_t = unsigned_integer_type;
| ^
/usr/include/stdint.h:73:33: note: previous declaration 'typedef long unsigned int uint_fast16_t'
73 | typedef unsigned long int uint_fast16_t;
| ^~~~~~~~~~~~~
p511.cpp:55:44: error: 'using uint_fast32_t = unsigned int' conflicts with a previous declaration
55 | using uint_fast32_t = unsigned_integer_type;
| ^
/usr/include/stdint.h:74:33: note: previous declaration 'typedef long unsigned int uint_fast32_t'
74 | typedef unsigned long int uint_fast32_t;
| ^~~~~~~~~~~~~
p511.cpp:56:44: error: 'using uint_fast64_t = unsigned int' conflicts with a previous declaration
56 | using uint_fast64_t = unsigned_integer_type;
| ^
/usr/include/stdint.h:75:33: note: previous declaration 'typedef long unsigned int uint_fast64_t'
75 | typedef unsigned long int uint_fast64_t;
| ^~~~~~~~~~~~~
p511.cpp:58:44: error: 'using uint_least8_t = unsigned int' conflicts with a previous declaration
58 | using uint_least8_t = unsigned_integer_type;
| ^
/usr/include/stdint.h:49:25: note: previous declaration 'typedef __uint_least8_t uint_least8_t'
49 | typedef __uint_least8_t uint_least8_t;
| ^~~~~~~~~~~~~
p511.cpp:59:45: error: 'using uint_least16_t = unsigned int' conflicts with a previous declaration
59 | using uint_least16_t = unsigned_integer_type;
| ^
/usr/include/stdint.h:50:26: note: previous declaration 'typedef __uint_least16_t uint_least16_t'
50 | typedef __uint_least16_t uint_least16_t;
| ^~~~~~~~~~~~~~
p511.cpp:61:45: error: 'using uint_least64_t = unsigned int' conflicts with a previous declaration
61 | using uint_least64_t = unsigned_integer_type;
| ^
/usr/include/stdint.h:52:26: note: previous declaration 'typedef __uint_least64_t uint_least64_t'
52 | typedef __uint_least64_t uint_least64_t;
| ^~~~~~~~~~~~~~
検討事項(agenda)
コンパイルエラーを取るか、コンパイルエラーの理由を解説する。
参考資料(reference)
cpprefjp - C++日本語リファレンス
コンパイラの実装状況
typedef は C++11 ではオワコン
C99からC++14を駆け抜けるC++講座
自己参照(self reference)
コピペコンパイルエラーあるある
C++ Error Message Collection(1)does not name a type, 11 articles
dockerにclang
docker gnu(gcc/g++) and llvm(clang/clang++)
コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
Compare the contents of C++N4910:2022, C++N4741:2018 and C++N4606:2015
C++ sample list
clang++, g++コンパイルエラー方針の違いの例
astyle 使ってみた
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.01 初稿 20220709