-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
268 lines (252 loc) · 11.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>cdecl+</title>
<link rel="stylesheet" href="css/fonts.css">
<link rel="stylesheet" href="css/style.css">
<link rel="icon" type="image/png" href="img/favicon.png"/>
</head>
<body>
<header>
<div id="source"><a href="https://github.com/Eisenwave/cdecl-plus">source code</a></div>
</header>
<main>
<h1>cdecl+</h1>
<h2>C Declarations & printf/scanf ➔ Prose</h2>
<textarea id="input" autocomplete="off" spellcheck="false" autofocus></textarea>
<div id="output">
<div id="examples">
<b>Examples:</b>
<ul id="examples-list">
<li tabindex="0">char const * const</li>
<li tabindex="0">int x; float y;</li>
<li tabindex="0">int(*(*)[10])()</li>
<li tabindex="0">typedef struct s {} s, *sptr</li>
<li tabindex="0">int(*(*arr)[10])()</li>
<li tabindex="0">void &(int[*]) _Atomic [0]</li>
<li tabindex="0">fprintf(stderr, "%#*.*LF", width, precision, number)</li>
<li tabindex="0">scanf("%4d/%2d/%2d", &year, &month, &day)</li>
</ul>
</div>
<div id="prose"></div>
</div>
<div id="diagnostics">
<div id="d-returning-array" class="d-error" hidden>
<span>Return type may not be an array</span>
</div>
<div id="d-returning-function" class="d-error" hidden>
<span>Return type may not be a function</span>
</div>
<div id="d-atomic-array" class="d-error" hidden>
<span>Can not create atomic array</span>
</div>
<div id="d-atomic-function" class="d-error" hidden>
<span>Can not create atomic function</span>
</div>
<div id="d-array-of-references" class="d-error" hidden>
<span>Can not create array of references</span>
</div>
<div id="d-array-of-functions" class="d-error" hidden>
<span>Can not create array of functions</span>
</div>
<div id="d-array-of-void" class="d-error" hidden>
<span>Can not create array of void, which is an incomplete type</span>
</div>
<div id="d-reference-to-void" class="d-error" hidden>
<span>Can not create reference to void</span>
</div>
<div id="d-reference-to-member" class="d-error" hidden>
<span>Can not create reference to member</span>
</div>
<div id="d-void-variable" class="d-error" hidden>
<span>Can not declare variable/parameter of type void</span>
</div>
<div id="d-qualified-void-parameter" class="d-error" hidden>
<span>Void as parameter must not have type qualifiers</span>
</div>
<div id="d-pointer-to-reference" class="d-error" hidden>
<span>Can not create pointer to reference</span>
</div>
<div id="d-qualified-array" class="d-error" hidden>
<span>Arrays with type qualifiers may only appear in function parameters</span>
</div>
<div id="d-non-parameter-vla" class="d-error" hidden>
<span>VLA of unspecified size may only appear in function parameters</span>
</div>
<div id="d-atomic-qualified-function" class="d-error" hidden>
<span>Functions may not be _Atomic-qualified</span>
</div>
<div id="d-restrict-qualified-function" class="d-error" hidden>
<span>Functions may not be restrict-qualified</span>
</div>
<div id="d-duplicate-pointer-qualifier" class="d-error" hidden>
<span>Duplicate qualifier on pointer</span>
</div>
<div id="d-duplicate-function-qualifier" class="d-error" hidden>
<span>Duplicate qualifier on function</span>
</div>
<div id="d-zero-size-array" class="d-warning" hidden>
<span>Zero-size arrays are a non-standard extension</span>
</div>
<div id="d-implicit-int" class="d-warning" hidden>
<span>Type is implicitly int</span>
</div>
<div id="d-implicit-double" class="d-warning" hidden>
<span>Implicit double type for complex specifier is non-standard</span>
</div>
<div id="d-array-to-pointer-decay" class="d-info" hidden>
<span>Parameter of array type decays to pointer</span>
</div>
<div id="d-function-to-pointer-decay" class="d-info" hidden>
<span>Parameter of function type decays to pointer to function</span>
</div>
<div id="d-empty-function-parameters" class="d-info" hidden>
<span>Function with empty parameter list takes unspecified number of parameters</span>
</div>
<div id="d-constexpr-implicit-const" class="d-info" hidden>
<span>constexpr adds an implicit const in this case</span>
</div>
<div id="d-format-syntax-error" class="d-error" hidden>
<span>The given format string is invalid. This results in undefined behaviour.</span>
</div>
<div id="d-format-not-enough-args" class="d-error" hidden>
<span>Not enough arguments were provided for the given format string.</span>
</div>
<div id="d-format-too-many-args" class="d-error" hidden>
<span>Too many arguments were provided for the given format string.</span>
</div>
<div id="d-printf-%%" class="d-error" hidden>
<span>%% can not accept any flags, width, precision, or length modifier</span>
</div>
<div id="d-scanf-%%" class="d-error" hidden>
<span>%% can not have assignment suppression, width, or length modifier</span>
</div>
<div id="d-scanf-unbounded-string" class="d-warning" hidden>
<span>%s or %[] with no width may lead to buffer overflow like
<a href="https://en.cppreference.com/w/c/io/gets" target="_blank">
gets
</a>
</span>
</div>
<div id="d-scanf-leading-whitespace-literal" class="d-warning" hidden>
<span>literals do not consume leading whitespace,
<a href="https://stackoverflow.com/q/26391465">
which may be a pitfall here
</a>
</span>
</div>
<div id="d-scanf-leading-whitespace" class="d-warning" hidden>
<span>%c and %[] do not consume leading whitespace,
<a href="https://stackoverflow.com/q/26391465">
which may be a pitfall here
</a>
</span>
</div>
<div id="d-scanf-max-field-width-_s" class="d-warning" hidden>
<span>Use of max field width AND receiving buffer size in _s functions is redundant</span>
</div>
<div id="d-format-bounds-checked" class="d-warning" hidden>
<span>Bounds-checked functions (_s) are optional (check #if __STDC_LIB_EXT1__ == 1)</span>
</div>
<div id="d-printf-io" class="d-info" hidden>
<span>printf outputs to
<a href="https://en.cppreference.com/w/cpp/io/c/std_streams" target="_blank">
stdout
</a>
</span>
</div>
<div id="d-fprintf-io" class="d-info" hidden>
<span>fprintf outputs to the given
<a href="https://en.cppreference.com/w/c/io/FILE" target="_blank">
file
</a>
</span>
</div>
<div id="d-sprintf-io" class="d-info" hidden>
<span>sprintf outputs to the given buffer (char*)</span>
</div>
<div id="d-snprintf-io" class="d-info" hidden>
<span>sprintf outputs to the given buffer (char*) and size (size_t)</span>
</div>
<div id="d-fprintf_s-io" class="d-info" hidden>
<span>fprintf_s outputs to the given
<a href="https://en.cppreference.com/w/c/io/FILE" target="_blank">
file
</a>
</span>
</div>
<div id="d-sprintf_s-io" class="d-info" hidden>
<span>sprintf_s outputs to the given buffer (char*) and size (rsize_t)</span>
</div>
<div id="d-snprintf_s-io" class="d-info" hidden>
<span>sprintf_s outputs to the given buffer (char*) and size (rsize_t)</span>
</div>
<div id="d-scanf-io" class="d-info" hidden>
<span>scanf reads from
<a href="https://en.cppreference.com/w/cpp/io/c/std_streams" target="_blank">
stdin
</a>
</span>
</div>
<div id="d-fscanf-io" class="d-info" hidden>
<span>fscanf reads from the given
<a href="https://en.cppreference.com/w/c/io/FILE" target="_blank">
file
</a>
</span>
</div>
<div id="d-sscanf-io" class="d-info" hidden>
<span>sscanf reads from the given null-terminated string (const char*)</span>
</div>
<div id="d-scanf_s-io" class="d-info" hidden>
<span>scanf_s reads from
<a href="https://en.cppreference.com/w/cpp/io/c/std_streams" target="_blank">
stdin
</a>
</span>
</div>
<div id="d-fscanf_s-io" class="d-info" hidden>
<span>fscanf_s reads from the given
<a href="https://en.cppreference.com/w/c/io/FILE" target="_blank">
file
</a>
</span>
</div>
<div id="d-sscanf_s-io" class="d-info" hidden>
<span>sscanf_s reads from the given null-terminated string (const char*)</span>
</div>
<div id="d-rsize_t" class="d-info" hidden>
<span>
<a href="https://port70.net/~nsz/c/c11/n1570.html#K.3.3p2" target="_blank">rsize_t</a>
is an alias for
<a href="https://port70.net/~nsz/c/c11/n1570.html#7.19p2" target="_blank">size_t</a>
with constraint
<a href="https://port70.net/~nsz/c/c11/n1570.html#K.3.4p2" target="_blank">RSIZE_MAX</a>
</span>
</div>
<div id="d-printf" class="d-info" hidden>
<span>For more info, see
<a href="https://en.cppreference.com/w/c/io/fprintf" target="_blank">
printf documentation
</a>
</span>
</div>
<div id="d-scanf" class="d-info" hidden>
<span>For more info, see
<a href="https://en.cppreference.com/w/c/io/fscanf" target="_blank">
scanf documentation
</a>
</span>
</div>
</div>
<p id="debug-output" hidden></p>
</main>
<div id="back"></div>
<footer>
<div id="author">by <a href="https://github.com/Eisenwave">eisenwave</a></div>
</footer>
<script src="js/main.js" type="module"></script>
</body>
</html>