はじめに(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.2.2 Header synopsis [cstdlib.syn] C++N4910:2022 (269) p496.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.2.2 Header <cstdlib> synopsis [cstdlib.syn] C++N4910:2022 (269) p496.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>
using namespace std;
// Example 1
namespace std {
using size_t = see below;
using div_t = see below;
using ldiv_t = see below;
using lldiv_t = see below;
}
#define NULL see_below
#define EXIT_FAILURE see_below
// #define EXIT_SUCCESS see_below
#define RAND_MAX see_below
#define MB_CUR_MAX see below
namespace std {
// Exposition-only function type aliases
extern "C" using c-atexit-handler = void();
extern "C++" using atexit-handler = void();
extern "C" using c-compare-pred = int(const void*, const void*);
extern "C++" using compare-pred = int(const void*, const void*);
// 17.5, start and termination
[[noreturn]] void abort() noexcept;
int atexit(c-atexit-handler* func) noexcept;
int atexit(atexit-handler* func) noexcept;
int at_quick_exit(c-atexit-handler* func) noexcept;
int at_quick_exit(atexit-handler* func) noexcept;
[[noreturn]] void exit(int status);
[[noreturn]] void _Exit(int status) noexcept;
[[noreturn]] void quick_exit(int status) noexcept;
char* getenv(const char* name);
int system(const char* string);
// 20.2.11, C library memory allocation
void* aligned_alloc(size_t alignment, size_t size);
void* calloc(size_t nmemb, size_t size);
void free(void* ptr);
void* malloc(size_t size);
void* realloc(void* ptr, size_t size);
double atof(const char* nptr);
int atoi(const char* nptr);
long int atol(const char* nptr);
long long int atoll(const char* nptr);
double strtod(const char* nptr, char** endptr);
float strtof(const char* nptr, char** endptr);
long double strtold(const char* nptr, char** endptr);
long int strtol(const char* nptr, char** endptr, int base);
long long int strtoll(const char* nptr, char** endptr, int base);
unsigned long int strtoul(const char* nptr, char** endptr, int base);
// exposition only // exposition only // exposition only // exposition only
unsigned long long int strtoull(const char* nptr, char** endptr, int base);
// 23.5.6, multibyte / wide string and character conversion functions int mblen(const char* s, size_t n);
int mbtowc(wchar_t* pwc, const char* s, size_t n);
int wctomb(char* s, wchar_t wchar);
size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
// 27.12, C standard library algorithms
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, c-compare-pred * compar);
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, compare-pred * compar);
void qsort(void* base, size_t nmemb, size_t size, c-compare-pred * compar);
void qsort(void* base, size_t nmemb, size_t size, compare-pred * compar);
// 28.5.10, low-quality random number generation int rand();
void srand(unsigned int seed);
// 28.7.2, absolute values
constexpr int abs(int j);
constexpr long int abs(long int j);
constexpr long long int abs(long long int j);
constexpr float abs(float j);
constexpr double abs(double j);
constexpr long double abs(long double j);
constexpr long int labs(long int j);
constexpr long long int llabs(long long int j);
constexpr div_t div(int numer, int denom);
constexpr ldiv_t div(long int numer, long int denom);
constexpr lldiv_t div(long long int numer, long long int denom);
constexpr ldiv_t ldiv(long int numer, long int denom);
constexpr lldiv_t lldiv(long long int numer, long long int denom);
}
// see 16.2 // see 16.2
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 p496
$ clang++ p496.cpp -std=c++03 -o p496l -I. -Wall
In file included from p496.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 \
^
p496.cpp:27:16: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using size_t = see below;
^
p496.cpp:27:16: error: unknown type name 'see'
p496.cpp:27:20: error: type-id cannot have a name
using size_t = see below;
^~~~~
p496.cpp:28:15: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using div_t = see below;
^
p496.cpp:28:15: error: unknown type name 'see'
p496.cpp:28:19: error: type-id cannot have a name
using div_t = see below;
^~~~~
p496.cpp:29:16: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using ldiv_t = see below;
^
p496.cpp:29:16: error: unknown type name 'see'
p496.cpp:29:20: error: type-id cannot have a name
using ldiv_t = see below;
^~~~~
p496.cpp:30:17: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using lldiv_t = see below;
^
p496.cpp:30:17: error: unknown type name 'see'
p496.cpp:30:21: error: type-id cannot have a name
using lldiv_t = see below;
^~~~~
p496.cpp:32:9: warning: 'NULL' macro redefined [-Wmacro-redefined]
#define NULL see_below
^
/usr/lib/llvm-14/lib/clang/14.0.5/include/stddef.h:84:13: note: previous definition is here
# define NULL __null
^
p496.cpp:33:9: warning: 'EXIT_FAILURE' macro redefined [-Wmacro-redefined]
#define EXIT_FAILURE see_below
^
/usr/include/stdlib.h:91:9: note: previous definition is here
#define EXIT_FAILURE 1 /* Failing exit status. */
^
p496.cpp:35:9: warning: 'RAND_MAX' macro redefined [-Wmacro-redefined]
#define RAND_MAX see_below
^
/usr/include/stdlib.h:86:9: note: previous definition is here
#define RAND_MAX 2147483647
^
p496.cpp:36:9: warning: 'MB_CUR_MAX' macro redefined [-Wmacro-redefined]
#define MB_CUR_MAX see below
^
/usr/include/stdlib.h:96:9: note: previous definition is here
#define MB_CUR_MAX (__ctype_get_mb_cur_max ())
^
p496.cpp:39:18: error: using declaration requires a qualified name
extern "C" using c-atexit-handler = void();
^
p496.cpp:39:19: error: expected ';' after using declaration
extern "C" using c-atexit-handler = void();
^
;
p496.cpp:40:20: error: using declaration requires a qualified name
extern "C++" using atexit-handler = void();
^
p496.cpp:40:26: error: expected ';' after using declaration
extern "C++" using atexit-handler = void();
^
;
p496.cpp:41:18: error: using declaration requires a qualified name
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
p496.cpp:41:19: error: expected ';' after using declaration
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
;
p496.cpp:41:85: error: using declaration requires a qualified name
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
p496.cpp:41:92: error: expected ';' after using declaration
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
;
p496.cpp:43:2: error: expected expression
[[noreturn]] void abort() noexcept;
^
p496.cpp:43:14: error: expected unqualified-id
[[noreturn]] void abort() noexcept;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
8 warnings and 20 errors generated.
rm: cannot remove 'p496l': No such file or directory
$ clang++ p496.cpp -std=c++2b -o p496l -I. -Wall
p496.cpp:27:16: error: unknown type name 'see'
using size_t = see below;
^
p496.cpp:27:20: error: type-id cannot have a name
using size_t = see below;
^~~~~
p496.cpp:28:15: error: unknown type name 'see'
using div_t = see below;
^
p496.cpp:28:19: error: type-id cannot have a name
using div_t = see below;
^~~~~
p496.cpp:29:16: error: unknown type name 'see'
using ldiv_t = see below;
^
p496.cpp:29:20: error: type-id cannot have a name
using ldiv_t = see below;
^~~~~
p496.cpp:30:17: error: unknown type name 'see'
using lldiv_t = see below;
^
p496.cpp:30:21: error: type-id cannot have a name
using lldiv_t = see below;
^~~~~
p496.cpp:32:9: warning: 'NULL' macro redefined [-Wmacro-redefined]
#define NULL see_below
^
/usr/lib/llvm-14/lib/clang/14.0.5/include/stddef.h:84:13: note: previous definition is here
# define NULL __null
^
p496.cpp:33:9: warning: 'EXIT_FAILURE' macro redefined [-Wmacro-redefined]
#define EXIT_FAILURE see_below
^
/usr/include/stdlib.h:91:9: note: previous definition is here
#define EXIT_FAILURE 1 /* Failing exit status. */
^
p496.cpp:35:9: warning: 'RAND_MAX' macro redefined [-Wmacro-redefined]
#define RAND_MAX see_below
^
/usr/include/stdlib.h:86:9: note: previous definition is here
#define RAND_MAX 2147483647
^
p496.cpp:36:9: warning: 'MB_CUR_MAX' macro redefined [-Wmacro-redefined]
#define MB_CUR_MAX see below
^
/usr/include/stdlib.h:96:9: note: previous definition is here
#define MB_CUR_MAX (__ctype_get_mb_cur_max ())
^
p496.cpp:39:18: error: using declaration requires a qualified name
extern "C" using c-atexit-handler = void();
^
p496.cpp:39:19: error: expected ';' after using declaration
extern "C" using c-atexit-handler = void();
^
;
p496.cpp:40:20: error: using declaration requires a qualified name
extern "C++" using atexit-handler = void();
^
p496.cpp:40:26: error: expected ';' after using declaration
extern "C++" using atexit-handler = void();
^
;
p496.cpp:41:18: error: using declaration requires a qualified name
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
p496.cpp:41:19: error: expected ';' after using declaration
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
;
p496.cpp:41:85: error: using declaration requires a qualified name
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
p496.cpp:41:92: error: expected ';' after using declaration
extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
^
;
p496.cpp:43:19: error: declaration conflicts with target of using declaration already in scope
[[noreturn]] void abort() noexcept;
^
/usr/include/stdlib.h:591:13: note: target of using declaration
extern void abort (void) __THROW __attribute__ ((__noreturn__));
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cstdlib:130:11: note: using declaration
using ::abort;
^
p496.cpp:44:5: error: declaration conflicts with target of using declaration already in scope
int atexit(c-atexit-handler* func) noexcept;
^
/usr/include/stdlib.h:595:12: note: target of using declaration
extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/cstdlib:134:11: note: using declaration
using ::atexit;
^
p496.cpp:44:12: error: use of undeclared identifier 'c'
int atexit(c-atexit-handler* func) noexcept;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 warnings and 20 errors generated.
$ g++ p496.cpp -std=c++03 -o p496g -I. -Wall
In file included from /usr/local/include/c++/12.1.0/atomic:38,
from p496.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 \
| ^~~~~
p496.cpp:32: warning: "NULL" redefined
32 | #define NULL see_below
|
In file included from /usr/include/string.h:33,
from /usr/local/include/c++/12.1.0/cstring:42,
from p496.cpp:13:
/usr/local/lib/gcc/x86_64-linux-gnu/12.1.0/include/stddef.h:401: note: this is the location of the previous definition
401 | #define NULL __null
|
p496.cpp:33: warning: "EXIT_FAILURE" redefined
33 | #define EXIT_FAILURE see_below
|
In file included from /usr/local/include/c++/12.1.0/cstdlib:75,
from p496.cpp:12:
/usr/include/stdlib.h:91: note: this is the location of the previous definition
91 | #define EXIT_FAILURE 1 /* Failing exit status. */
|
p496.cpp:35: warning: "RAND_MAX" redefined
35 | #define RAND_MAX see_below
|
/usr/include/stdlib.h:86: note: this is the location of the previous definition
86 | #define RAND_MAX 2147483647
|
p496.cpp:36: warning: "MB_CUR_MAX" redefined
36 | #define MB_CUR_MAX see below
|
/usr/include/stdlib.h:96: note: this is the location of the previous definition
96 | #define MB_CUR_MAX (__ctype_get_mb_cur_max ())
|
p496.cpp:43:27: warning: identifier 'noexcept' is a keyword in C++11 [-Wc++11-compat]
43 | [[noreturn]] void abort() noexcept;
| ^~~~~~~~
p496.cpp:80:1: warning: identifier 'constexpr' is a keyword in C++11 [-Wc++11-compat]
80 | constexpr int abs(int j);
| ^~~~~~~~~
p496.cpp:27:7: error: expected nested-name-specifier before 'size_t'
27 | using size_t = see below;
| ^~~~~~
p496.cpp:28:7: error: expected nested-name-specifier before 'div_t'
28 | using div_t = see below;
| ^~~~~
p496.cpp:29:7: error: expected nested-name-specifier before 'ldiv_t'
29 | using ldiv_t = see below;
| ^~~~~~
p496.cpp:30:7: error: expected nested-name-specifier before 'lldiv_t'
30 | using lldiv_t = see below;
| ^~~~~~~
p496.cpp:39:18: error: expected nested-name-specifier before 'c'
39 | extern "C" using c-atexit-handler = void();
| ^
p496.cpp:40:20: error: expected nested-name-specifier before 'atexit'
40 | extern "C++" using atexit-handler = void();
| ^~~~~~
p496.cpp:41:18: error: expected nested-name-specifier before 'c'
41 | extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
| ^
p496.cpp:41:85: error: expected nested-name-specifier before 'compare'
41 | extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
| ^~~~~~~
p496.cpp:43:1: error: expected unqualified-id before '[' token
43 | [[noreturn]] void abort() noexcept;
| ^
p496.cpp:44:12: error: 'int std::atexit' conflicts with a previous declaration
44 | int atexit(c-atexit-handler* func) noexcept;
| ^
/usr/include/stdlib.h:595:12: note: previous declaration 'int atexit(void (*)())'
595 | extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
| ^~~~~~
p496.cpp:44:12: error: 'c' was not declared in this scope
44 | int atexit(c-atexit-handler* func) noexcept;
| ^
p496.cpp:44:21: error: 'handler' was not declared in this scope
44 | int atexit(c-atexit-handler* func) noexcept;
| ^~~~~~~
p496.cpp:44:30: error: 'func' was not declared in this scope
44 | int atexit(c-atexit-handler* func) noexcept;
| ^~~~
p496.cpp:45:12: error: 'int std::atexit' conflicts with a previous declaration
45 | int atexit(atexit-handler* func) noexcept;
| ^~~~~~
/usr/include/stdlib.h:595:12: note: previous declaration 'int atexit(void (*)())'
595 | extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
| ^~~~~~
p496.cpp:45:19: error: 'handler' was not declared in this scope
45 | int atexit(atexit-handler* func) noexcept;
| ^~~~~~~
p496.cpp:45:28: error: 'func' was not declared in this scope
45 | int atexit(atexit-handler* func) noexcept;
| ^~~~
p496.cpp:46:19: error: 'c' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^
p496.cpp:46:28: error: 'handler' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~~~~
p496.cpp:46:37: error: 'func' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~
p496.cpp:46:57: error: redefinition of 'int std::at_quick_exit'
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~~~~~~~~~~
p496.cpp:46:5: note: 'int std::at_quick_exit' previously defined here
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~~~~~~~~~~
p496.cpp:46:78: error: 'handler' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~~~~
p496.cpp:46:87: error: 'func' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~
p496.cpp:46:103: error: expected unqualified-id before '[' token
46 | _quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^
p496.cpp:47:1: error: expected unqualified-id before '[' token
47 | [[noreturn]] void _Exit(int status) noexcept; [[noreturn]] void quick_exit(int status) noexcept;
| ^
p496.cpp:47:47: error: expected unqualified-id before '[' token
47 | [[noreturn]] void _Exit(int status) noexcept; [[noreturn]] void quick_exit(int status) noexcept;
| ^
p496.cpp:48:34: error: 'char* std::getenv(const char*)' conflicts with a previous declaration
48 | char* getenv(const char* name);
| ^
/usr/include/stdlib.h:634:14: note: previous declaration 'char* getenv(const char*)'
634 | extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
| ^~~~~~
p496.cpp:49:34: error: 'int std::system(const char*)' conflicts with a previous declaration
49 | int system(const char* string);
| ^
/usr/include/stdlib.h:784:12: note: previous declaration 'int system(const char*)'
784 | extern int system (const char *__command) __wur;
| ^~~~~~
p496.cpp:51:91: error: 'void* std::calloc(size_t, size_t)' conflicts with a previous declaration
51 | void* aligned_alloc(size_t alignment, size_t size); void* calloc(size_t nmemb, size_t size);
| ^
/usr/include/stdlib.h:542:14: note: previous declaration 'void* calloc(size_t, size_t)'
542 | extern void *calloc (size_t __nmemb, size_t __size)
| ^~~~~~
p496.cpp:52:20: error: 'void std::free(void*)' conflicts with a previous declaration
52 | void free(void* ptr);
| ^
/usr/include/stdlib.h:565:13: note: previous declaration 'void free(void*)'
565 | extern void free (void *__ptr) __THROW;
| ^~~~
p496.cpp:53:25: error: 'void* std::malloc(size_t)' conflicts with a previous declaration
53 | void* malloc(size_t size);
| ^
/usr/include/stdlib.h:539:14: note: previous declaration 'void* malloc(size_t)'
539 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
| ^~~~~~
p496.cpp:54:37: error: 'void* std::realloc(void*, size_t)' conflicts with a previous declaration
54 | void* realloc(void* ptr, size_t size);
| ^
/usr/include/stdlib.h:550:14: note: previous declaration 'void* realloc(void*, size_t)'
550 | extern void *realloc (void *__ptr, size_t __size)
| ^~~~~~~
p496.cpp:55:29: error: 'double std::atof(const char*)' conflicts with a previous declaration
55 | double atof(const char* nptr);
| ^
/usr/include/stdlib.h:101:15: note: previous declaration 'double atof(const char*)'
101 | extern double atof (const char *__nptr)
| ^~~~
p496.cpp:56:26: error: 'int std::atoi(const char*)' conflicts with a previous declaration
56 | int atoi(const char* nptr);
| ^
/usr/include/stdlib.h:104:12: note: previous declaration 'int atoi(const char*)'
104 | extern int atoi (const char *__nptr)
| ^~~~
p496.cpp:57:31: error: 'long int std::atol(const char*)' conflicts with a previous declaration
57 | long int atol(const char* nptr);
| ^
/usr/include/stdlib.h:107:17: note: previous declaration 'long int atol(const char*)'
107 | extern long int atol (const char *__nptr)
| ^~~~
p496.cpp:58:37: error: 'long long int std::atoll(const char*)' conflicts with a previous declaration
58 | long long int atoll(const char* nptr);
| ^
/usr/include/stdlib.h:112:36: note: previous declaration 'long long int atoll(const char*)'
112 | __extension__ extern long long int atoll (const char *__nptr)
| ^~~~~
p496.cpp:59:46: error: 'double std::strtod(const char*, char**)' conflicts with a previous declaration
59 | double strtod(const char* nptr, char** endptr);
| ^
/usr/include/stdlib.h:117:15: note: previous declaration 'double strtod(const char*, char**)'
117 | extern double strtod (const char *__restrict __nptr,
| ^~~~~~
p496.cpp:60:45: error: 'float std::strtof(const char*, char**)' conflicts with a previous declaration
60 | float strtof(const char* nptr, char** endptr);
| ^
/usr/include/stdlib.h:123:14: note: previous declaration 'float strtof(const char*, char**)'
123 | extern float strtof (const char *__restrict __nptr,
| ^~~~~~
p496.cpp:61:52: error: 'long double std::strtold(const char*, char**)' conflicts with a previous declaration
61 | long double strtold(const char* nptr, char** endptr);
| ^
/usr/include/stdlib.h:126:20: note: previous declaration 'long double strtold(const char*, char**)'
126 | extern long double strtold (const char *__restrict __nptr,
| ^~~~~~~
p496.cpp:62:58: error: 'long int std::strtol(const char*, char**, int)' conflicts with a previous declaration
62 | long int strtol(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:176:17: note: previous declaration 'long int strtol(const char*, char**, int)'
176 | extern long int strtol (const char *__restrict __nptr,
| ^~~~~~
p496.cpp:63:64: error: 'long long int std::strtoll(const char*, char**, int)' conflicts with a previous declaration
63 | long long int strtoll(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:200:22: note: previous declaration 'long long int strtoll(const char*, char**, int)'
200 | extern long long int strtoll (const char *__restrict __nptr,
| ^~~~~~~
p496.cpp:64:68: error: 'long unsigned int std::strtoul(const char*, char**, int)' conflicts with a previous declaration
64 | unsigned long int strtoul(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:180:26: note: previous declaration 'long unsigned int strtoul(const char*, char**, int)'
180 | extern unsigned long int strtoul (const char *__restrict __nptr,
| ^~~~~~~
p496.cpp:66:74: error: 'long long unsigned int std::strtoull(const char*, char**, int)' conflicts with a previous declaration
66 | unsigned long long int strtoull(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:205:31: note: previous declaration 'long long unsigned int strtoull(const char*, char**, int)'
205 | extern unsigned long long int strtoull (const char *__restrict __nptr,
| ^~~~~~~~
p496.cpp:68:49: error: 'int std::mbtowc(wchar_t*, const char*, size_t)' conflicts with a previous declaration
68 | int mbtowc(wchar_t* pwc, const char* s, size_t n);
| ^
/usr/include/stdlib.h:925:12: note: previous declaration 'int mbtowc(wchar_t*, const char*, size_t)'
925 | extern int mbtowc (wchar_t *__restrict __pwc,
| ^~~~~~
p496.cpp:69:34: error: 'int std::wctomb(char*, wchar_t)' conflicts with a previous declaration
69 | int wctomb(char* s, wchar_t wchar);
| ^
/usr/include/stdlib.h:929:12: note: previous declaration 'int wctomb(char*, wchar_t)'
929 | extern int wctomb (char *__s, wchar_t __wchar) __THROW;
| ^~~~~~
p496.cpp:70:55: error: 'std::size_t std::mbstowcs(wchar_t*, const char*, size_t)' conflicts with a previous declaration
70 | size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
| ^
/usr/include/stdlib.h:933:15: note: previous declaration 'size_t mbstowcs(wchar_t*, const char*, size_t)'
933 | extern size_t mbstowcs (wchar_t *__restrict __pwcs,
| ^~~~~~~~
p496.cpp:71:55: error: 'std::size_t std::wcstombs(char*, const wchar_t*, size_t)' conflicts with a previous declaration
71 | size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
| ^
/usr/include/stdlib.h:936:15: note: previous declaration 'size_t wcstombs(char*, const wchar_t*, size_t)'
936 | extern size_t wcstombs (char *__restrict __s,
| ^~~~~~~~
p496.cpp:73:77: error: 'c' has not been declared
73 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:73:78: error: expected ',' or '...' before '-' token
73 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:74:77: error: 'compare' has not been declared
74 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^~~~~~~
p496.cpp:74:84: error: expected ',' or '...' before '-' token
74 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^
p496.cpp:75:51: error: 'c' has not been declared
75 | void qsort(void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:75:52: error: expected ',' or '...' before '-' token
75 | void qsort(void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:76:51: error: 'compare' has not been declared
76 | void qsort(void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^~~~~~~
p496.cpp:76:58: error: expected ',' or '...' before '-' token
76 | void qsort(void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^
p496.cpp:78:29: error: 'void std::srand(unsigned int)' conflicts with a previous declaration
78 | void srand(unsigned int seed);
| ^
/usr/include/stdlib.h:455:13: note: previous declaration 'void srand(unsigned int)'
455 | extern void srand (unsigned int __seed) __THROW;
| ^~~~~
p496.cpp:80:1: error: 'constexpr' does not name a type
80 | constexpr int abs(int j);
| ^~~~~~~~~
p496.cpp:80:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:81:1: error: 'constexpr' does not name a type
81 | constexpr long int abs(long int j);
| ^~~~~~~~~
p496.cpp:81:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:82:1: error: 'constexpr' does not name a type
82 | constexpr long long int abs(long long int j);
| ^~~~~~~~~
p496.cpp:82:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:83:1: error: 'constexpr' does not name a type
83 | constexpr float abs(float j);
| ^~~~~~~~~
p496.cpp:83:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:84:1: error: 'constexpr' does not name a type
84 | constexpr double abs(double j);
| ^~~~~~~~~
p496.cpp:84:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:85:1: error: 'constexpr' does not name a type
85 | constexpr long double abs(long double j);
| ^~~~~~~~~
p496.cpp:85:1: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:86:3: error: 'constexpr' does not name a type
86 | constexpr long int labs(long int j);
| ^~~~~~~~~
p496.cpp:86:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:87:3: error: 'constexpr' does not name a type
87 | constexpr long long int llabs(long long int j);
| ^~~~~~~~~
p496.cpp:87:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:88:3: error: 'constexpr' does not name a type
88 | constexpr div_t div(int numer, int denom);
| ^~~~~~~~~
p496.cpp:88:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:89:3: error: 'constexpr' does not name a type
89 | constexpr ldiv_t div(long int numer, long int denom);
| ^~~~~~~~~
p496.cpp:89:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:90:3: error: 'constexpr' does not name a type
90 | constexpr lldiv_t div(long long int numer, long long int denom);
| ^~~~~~~~~
p496.cpp:90:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:91:3: error: 'constexpr' does not name a type
91 | constexpr ldiv_t ldiv(long int numer, long int denom);
| ^~~~~~~~~
p496.cpp:91:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
p496.cpp:92:3: error: 'constexpr' does not name a type
92 | constexpr lldiv_t lldiv(long long int numer, long long int denom);
| ^~~~~~~~~
p496.cpp:92:3: note: C++11 'constexpr' only available with '-std=c++11' or '-std=gnu++11'
rm: cannot remove 'p496g': No such file or directory
$ g++ p496.cpp -std=c++2b -o p496g -I. -Wall
p496.cpp:32: warning: "NULL" redefined
32 | #define NULL see_below
|
In file included from /usr/include/unistd.h:226,
from /usr/local/include/c++/12.1.0/bits/atomic_wait.h:44,
from /usr/local/include/c++/12.1.0/bits/atomic_base.h:41,
from /usr/local/include/c++/12.1.0/atomic:41,
from p496.cpp:19:
/usr/local/lib/gcc/x86_64-linux-gnu/12.1.0/include/stddef.h:401: note: this is the location of the previous definition
401 | #define NULL __null
|
p496.cpp:33: warning: "EXIT_FAILURE" redefined
33 | #define EXIT_FAILURE see_below
|
In file included from /usr/local/include/c++/12.1.0/cstdlib:75,
from /usr/local/include/c++/12.1.0/ext/string_conversions.h:41,
from /usr/local/include/c++/12.1.0/bits/basic_string.h:3960,
from /usr/local/include/c++/12.1.0/string:53,
from /usr/local/include/c++/12.1.0/bits/locale_classes.h:40,
from /usr/local/include/c++/12.1.0/bits/ios_base.h:41,
from /usr/local/include/c++/12.1.0/ios:42,
from /usr/local/include/c++/12.1.0/ostream:38,
from /usr/local/include/c++/12.1.0/iostream:39,
from p496.cpp:10:
/usr/include/stdlib.h:91: note: this is the location of the previous definition
91 | #define EXIT_FAILURE 1 /* Failing exit status. */
|
p496.cpp:35: warning: "RAND_MAX" redefined
35 | #define RAND_MAX see_below
|
/usr/include/stdlib.h:86: note: this is the location of the previous definition
86 | #define RAND_MAX 2147483647
|
p496.cpp:36: warning: "MB_CUR_MAX" redefined
36 | #define MB_CUR_MAX see below
|
/usr/include/stdlib.h:96: note: this is the location of the previous definition
96 | #define MB_CUR_MAX (__ctype_get_mb_cur_max ())
|
p496.cpp:27:16: error: 'see' does not name a type
27 | using size_t = see below;
| ^~~
p496.cpp:28:15: error: 'see' does not name a type
28 | using div_t = see below;
| ^~~
p496.cpp:29:16: error: 'see' does not name a type
29 | using ldiv_t = see below;
| ^~~
p496.cpp:30:17: error: 'see' does not name a type
30 | using lldiv_t = see below;
| ^~~
p496.cpp:39:18: error: expected nested-name-specifier before 'c'
39 | extern "C" using c-atexit-handler = void();
| ^
p496.cpp:40:20: error: expected nested-name-specifier before 'atexit'
40 | extern "C++" using atexit-handler = void();
| ^~~~~~
p496.cpp:41:18: error: expected nested-name-specifier before 'c'
41 | extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
| ^
p496.cpp:41:85: error: expected nested-name-specifier before 'compare'
41 | extern "C" using c-compare-pred = int(const void*, const void*); extern "C++" using compare-pred = int(const void*, const void*);
| ^~~~~~~
p496.cpp:43:27: error: 'void std::abort()' conflicts with a previous declaration
43 | [[noreturn]] void abort() noexcept;
| ^~~~~~~~
/usr/include/stdlib.h:591:13: note: previous declaration 'void abort()'
591 | extern void abort (void) __THROW __attribute__ ((__noreturn__));
| ^~~~~
p496.cpp:44:12: error: 'int std::atexit' conflicts with a previous declaration
44 | int atexit(c-atexit-handler* func) noexcept;
| ^
/usr/include/stdlib.h:595:12: note: previous declaration 'int atexit(void (*)())'
595 | extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
| ^~~~~~
p496.cpp:44:12: error: 'c' was not declared in this scope
44 | int atexit(c-atexit-handler* func) noexcept;
| ^
p496.cpp:44:21: error: 'handler' was not declared in this scope
44 | int atexit(c-atexit-handler* func) noexcept;
| ^~~~~~~
p496.cpp:44:30: error: 'func' was not declared in this scope
44 | int atexit(c-atexit-handler* func) noexcept;
| ^~~~
p496.cpp:45:12: error: 'int std::atexit' conflicts with a previous declaration
45 | int atexit(atexit-handler* func) noexcept;
| ^~~~~~
/usr/include/stdlib.h:595:12: note: previous declaration 'int atexit(void (*)())'
595 | extern int atexit (void (*__func) (void)) __THROW __nonnull ((1));
| ^~~~~~
p496.cpp:45:19: error: 'handler' was not declared in this scope
45 | int atexit(atexit-handler* func) noexcept;
| ^~~~~~~
p496.cpp:45:28: error: 'func' was not declared in this scope
45 | int atexit(atexit-handler* func) noexcept;
| ^~~~
p496.cpp:46:19: error: 'int std::at_quick_exit' conflicts with a previous declaration
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^
/usr/include/stdlib.h:600:18: note: previous declaration 'int at_quick_exit(void (*)())'
600 | extern "C++" int at_quick_exit (void (*__func) (void))
| ^~~~~~~~~~~~~
p496.cpp:46:19: error: 'c' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^
p496.cpp:46:28: error: 'handler' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~~~~
p496.cpp:46:37: error: 'func' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~
p496.cpp:46:71: error: 'int std::at_quick_exit' conflicts with a previous declaration
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~~~
/usr/include/stdlib.h:600:18: note: previous declaration 'int at_quick_exit(void (*)())'
600 | extern "C++" int at_quick_exit (void (*__func) (void))
| ^~~~~~~~~~~~~
p496.cpp:46:78: error: 'handler' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~~~~
p496.cpp:46:87: error: 'func' was not declared in this scope
46 | int at_quick_exit(c-atexit-handler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^~~~
p496.cpp:46:136: error: 'void std::exit(int)' conflicts with a previous declaration
46 | dler* func) noexcept; int at_quick_exit(atexit-handler* func) noexcept; [[noreturn]] void exit(int status);
| ^
/usr/include/stdlib.h:617:13: note: previous declaration 'void exit(int)'
617 | extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
| ^~~~
p496.cpp:47:37: error: 'void std::_Exit(int)' conflicts with a previous declaration
47 | [[noreturn]] void _Exit(int status) noexcept; [[noreturn]] void quick_exit(int status) noexcept;
| ^~~~~~~~
/usr/include/stdlib.h:629:13: note: previous declaration 'void _Exit(int)'
629 | extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__));
| ^~~~~
p496.cpp:47:88: error: 'void std::quick_exit(int)' conflicts with a previous declaration
47 | [[noreturn]] void _Exit(int status) noexcept; [[noreturn]] void quick_exit(int status) noexcept;
| ^~~~~~~~
/usr/include/stdlib.h:623:13: note: previous declaration 'void quick_exit(int)'
623 | extern void quick_exit (int __status) __THROW __attribute__ ((__noreturn__));
| ^~~~~~~~~~
p496.cpp:48:34: error: 'char* std::getenv(const char*)' conflicts with a previous declaration
48 | char* getenv(const char* name);
| ^
/usr/include/stdlib.h:634:14: note: previous declaration 'char* getenv(const char*)'
634 | extern char *getenv (const char *__name) __THROW __nonnull ((1)) __wur;
| ^~~~~~
p496.cpp:49:34: error: 'int std::system(const char*)' conflicts with a previous declaration
49 | int system(const char* string);
| ^
/usr/include/stdlib.h:784:12: note: previous declaration 'int system(const char*)'
784 | extern int system (const char *__command) __wur;
| ^~~~~~
p496.cpp:51:50: error: 'void* std::aligned_alloc(size_t, size_t)' conflicts with a previous declaration
51 | void* aligned_alloc(size_t alignment, size_t size); void* calloc(size_t nmemb, size_t size);
| ^
/usr/include/stdlib.h:586:14: note: previous declaration 'void* aligned_alloc(size_t, size_t)'
586 | extern void *aligned_alloc (size_t __alignment, size_t __size)
| ^~~~~~~~~~~~~
p496.cpp:51:91: error: 'void* std::calloc(size_t, size_t)' conflicts with a previous declaration
51 | void* aligned_alloc(size_t alignment, size_t size); void* calloc(size_t nmemb, size_t size);
| ^
/usr/include/stdlib.h:542:14: note: previous declaration 'void* calloc(size_t, size_t)'
542 | extern void *calloc (size_t __nmemb, size_t __size)
| ^~~~~~
p496.cpp:52:20: error: 'void std::free(void*)' conflicts with a previous declaration
52 | void free(void* ptr);
| ^
/usr/include/stdlib.h:565:13: note: previous declaration 'void free(void*)'
565 | extern void free (void *__ptr) __THROW;
| ^~~~
p496.cpp:53:25: error: 'void* std::malloc(size_t)' conflicts with a previous declaration
53 | void* malloc(size_t size);
| ^
/usr/include/stdlib.h:539:14: note: previous declaration 'void* malloc(size_t)'
539 | extern void *malloc (size_t __size) __THROW __attribute_malloc__
| ^~~~~~
p496.cpp:54:37: error: 'void* std::realloc(void*, size_t)' conflicts with a previous declaration
54 | void* realloc(void* ptr, size_t size);
| ^
/usr/include/stdlib.h:550:14: note: previous declaration 'void* realloc(void*, size_t)'
550 | extern void *realloc (void *__ptr, size_t __size)
| ^~~~~~~
p496.cpp:55:29: error: 'double std::atof(const char*)' conflicts with a previous declaration
55 | double atof(const char* nptr);
| ^
/usr/include/stdlib.h:101:15: note: previous declaration 'double atof(const char*)'
101 | extern double atof (const char *__nptr)
| ^~~~
p496.cpp:56:26: error: 'int std::atoi(const char*)' conflicts with a previous declaration
56 | int atoi(const char* nptr);
| ^
/usr/include/stdlib.h:104:12: note: previous declaration 'int atoi(const char*)'
104 | extern int atoi (const char *__nptr)
| ^~~~
p496.cpp:57:31: error: 'long int std::atol(const char*)' conflicts with a previous declaration
57 | long int atol(const char* nptr);
| ^
/usr/include/stdlib.h:107:17: note: previous declaration 'long int atol(const char*)'
107 | extern long int atol (const char *__nptr)
| ^~~~
p496.cpp:58:37: error: 'long long int std::atoll(const char*)' conflicts with a previous declaration
58 | long long int atoll(const char* nptr);
| ^
/usr/include/stdlib.h:112:36: note: previous declaration 'long long int atoll(const char*)'
112 | __extension__ extern long long int atoll (const char *__nptr)
| ^~~~~
p496.cpp:59:46: error: 'double std::strtod(const char*, char**)' conflicts with a previous declaration
59 | double strtod(const char* nptr, char** endptr);
| ^
/usr/include/stdlib.h:117:15: note: previous declaration 'double strtod(const char*, char**)'
117 | extern double strtod (const char *__restrict __nptr,
| ^~~~~~
p496.cpp:60:45: error: 'float std::strtof(const char*, char**)' conflicts with a previous declaration
60 | float strtof(const char* nptr, char** endptr);
| ^
/usr/include/stdlib.h:123:14: note: previous declaration 'float strtof(const char*, char**)'
123 | extern float strtof (const char *__restrict __nptr,
| ^~~~~~
p496.cpp:61:52: error: 'long double std::strtold(const char*, char**)' conflicts with a previous declaration
61 | long double strtold(const char* nptr, char** endptr);
| ^
/usr/include/stdlib.h:126:20: note: previous declaration 'long double strtold(const char*, char**)'
126 | extern long double strtold (const char *__restrict __nptr,
| ^~~~~~~
p496.cpp:62:58: error: 'long int std::strtol(const char*, char**, int)' conflicts with a previous declaration
62 | long int strtol(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:176:17: note: previous declaration 'long int strtol(const char*, char**, int)'
176 | extern long int strtol (const char *__restrict __nptr,
| ^~~~~~
p496.cpp:63:64: error: 'long long int std::strtoll(const char*, char**, int)' conflicts with a previous declaration
63 | long long int strtoll(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:200:22: note: previous declaration 'long long int strtoll(const char*, char**, int)'
200 | extern long long int strtoll (const char *__restrict __nptr,
| ^~~~~~~
p496.cpp:64:68: error: 'long unsigned int std::strtoul(const char*, char**, int)' conflicts with a previous declaration
64 | unsigned long int strtoul(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:180:26: note: previous declaration 'long unsigned int strtoul(const char*, char**, int)'
180 | extern unsigned long int strtoul (const char *__restrict __nptr,
| ^~~~~~~
p496.cpp:66:74: error: 'long long unsigned int std::strtoull(const char*, char**, int)' conflicts with a previous declaration
66 | unsigned long long int strtoull(const char* nptr, char** endptr, int base);
| ^
/usr/include/stdlib.h:205:31: note: previous declaration 'long long unsigned int strtoull(const char*, char**, int)'
205 | extern unsigned long long int strtoull (const char *__restrict __nptr,
| ^~~~~~~~
p496.cpp:68:49: error: 'int std::mbtowc(wchar_t*, const char*, size_t)' conflicts with a previous declaration
68 | int mbtowc(wchar_t* pwc, const char* s, size_t n);
| ^
/usr/include/stdlib.h:925:12: note: previous declaration 'int mbtowc(wchar_t*, const char*, size_t)'
925 | extern int mbtowc (wchar_t *__restrict __pwc,
| ^~~~~~
p496.cpp:69:34: error: 'int std::wctomb(char*, wchar_t)' conflicts with a previous declaration
69 | int wctomb(char* s, wchar_t wchar);
| ^
/usr/include/stdlib.h:929:12: note: previous declaration 'int wctomb(char*, wchar_t)'
929 | extern int wctomb (char *__s, wchar_t __wchar) __THROW;
| ^~~~~~
p496.cpp:70:55: error: 'std::size_t std::mbstowcs(wchar_t*, const char*, size_t)' conflicts with a previous declaration
70 | size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
| ^
/usr/include/stdlib.h:933:15: note: previous declaration 'size_t mbstowcs(wchar_t*, const char*, size_t)'
933 | extern size_t mbstowcs (wchar_t *__restrict __pwcs,
| ^~~~~~~~
p496.cpp:71:55: error: 'std::size_t std::wcstombs(char*, const wchar_t*, size_t)' conflicts with a previous declaration
71 | size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
| ^
/usr/include/stdlib.h:936:15: note: previous declaration 'size_t wcstombs(char*, const wchar_t*, size_t)'
936 | extern size_t wcstombs (char *__restrict __s,
| ^~~~~~~~
p496.cpp:73:77: error: 'c' has not been declared
73 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:73:78: error: expected ',' or '...' before '-' token
73 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:74:77: error: 'compare' has not been declared
74 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^~~~~~~
p496.cpp:74:84: error: expected ',' or '...' before '-' token
74 | void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^
p496.cpp:75:51: error: 'c' has not been declared
75 | void qsort(void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:75:52: error: expected ',' or '...' before '-' token
75 | void qsort(void* base, size_t nmemb, size_t size, c-compare-pred * compar);
| ^
p496.cpp:76:51: error: 'compare' has not been declared
76 | void qsort(void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^~~~~~~
p496.cpp:76:58: error: expected ',' or '...' before '-' token
76 | void qsort(void* base, size_t nmemb, size_t size, compare-pred * compar);
| ^
p496.cpp:78:29: error: 'void std::srand(unsigned int)' conflicts with a previous declaration
78 | void srand(unsigned int seed);
| ^
/usr/include/stdlib.h:455:13: note: previous declaration 'void srand(unsigned int)'
455 | extern void srand (unsigned int __seed) __THROW;
| ^~~~~
p496.cpp:80:24: error: 'constexpr int std::abs(int)' conflicts with a previous declaration
80 | constexpr int abs(int j);
| ^
/usr/include/stdlib.h:840:12: note: previous declaration 'int abs(int)'
840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
p496.cpp:81:20: error: redeclaration 'constexpr long int std::abs(long int)' differs in 'constexpr' from previous declaration
81 | constexpr long int abs(long int j);
| ^~~
In file included from /usr/local/include/c++/12.1.0/cstdlib:77:
/usr/local/include/c++/12.1.0/bits/std_abs.h:56:3: note: previous declaration 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
p496.cpp:82:25: error: redeclaration 'constexpr long long int std::abs(long long int)' differs in 'constexpr' from previous declaration
82 | constexpr long long int abs(long long int j);
| ^~~
/usr/local/include/c++/12.1.0/bits/std_abs.h:61:3: note: previous declaration 'long long int std::abs(long long int'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
p496.cpp:86:37: error: 'constexpr long int std::labs(long int)' conflicts with a previous declaration
86 | constexpr long int labs(long int j);
| ^
/usr/include/stdlib.h:841:17: note: previous declaration 'long int labs(long int)'
841 | extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~~
p496.cpp:87:48: error: 'constexpr long long int std::llabs(long long int)' conflicts with a previous declaration
87 | constexpr long long int llabs(long long int j);
| ^
/usr/include/stdlib.h:844:36: note: previous declaration 'long long int llabs(long long int)'
844 | __extension__ extern long long int llabs (long long int __x)
| ^~~~~
p496.cpp:88:43: error: 'constexpr div_t std::div(int, int)' conflicts with a previous declaration
88 | constexpr div_t div(int numer, int denom);
| ^
/usr/include/stdlib.h:852:14: note: previous declaration 'div_t div(int, int)'
852 | extern div_t div (int __numer, int __denom)
| ^~~
p496.cpp:89:20: error: redeclaration 'constexpr ldiv_t std::div(long int, long int)' differs in 'constexpr' from previous declaration
89 | constexpr ldiv_t div(long int numer, long int denom);
| ^~~
/usr/local/include/c++/12.1.0/cstdlib:177:3: note: previous declaration 'ldiv_t std::div(long int, long int)'
177 | div(long __i, long __j) { return ldiv(__i, __j); }
| ^~~
p496.cpp:90:65: error: 'constexpr lldiv_t std::div(long long int, long long int)' conflicts with a previous declaration
90 | constexpr lldiv_t div(long long int numer, long long int denom);
| ^
/usr/local/include/c++/12.1.0/cstdlib:213:3: note: previous declaration 'lldiv_t __gnu_cxx::div(long long int, long long int)'
213 | div(long long __n, long long __d)
| ^~~
p496.cpp:91:55: error: 'constexpr ldiv_t std::ldiv(long int, long int)' conflicts with a previous declaration
91 | constexpr ldiv_t ldiv(long int numer, long int denom);
| ^
/usr/include/stdlib.h:854:15: note: previous declaration 'ldiv_t ldiv(long int, long int)'
854 | extern ldiv_t ldiv (long int __numer, long int __denom)
| ^~~~
p496.cpp:92:67: error: 'constexpr lldiv_t std::lldiv(long long int, long long int)' conflicts with a previous declaration
92 | constexpr lldiv_t lldiv(long long int numer, long long int denom);
| ^
/usr/include/stdlib.h:858:30: note: previous declaration 'lldiv_t lldiv(long long int, long long int)'
858 | __extension__ extern lldiv_t lldiv (long long int __numer,
| ^~~~~
検討事項(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 初稿 20220708