Skip to content

Commit b7e97a5

Browse files
committed
fix(reference/{cstdio,cstdlib}): C互換ヘッダの関数・型は std:: をつけなきゃダメ!
1 parent 61a0b4d commit b7e97a5

File tree

18 files changed

+107
-93
lines changed

18 files changed

+107
-93
lines changed

reference/cstdio/eof.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
#include <cstdio>
1717
int main() {
1818
int c;
19-
while ((c = getchar()) != EOF) {
20-
putchar(c);
19+
while ((c = std::getchar()) != EOF) {
20+
std::putchar(c);
2121
}
2222
if (c == EOF)
23-
puts("REACHED END");
23+
std::puts("REACHED END");
2424
}
2525
2626
```
2727
* EOF[color ff0000]
28-
* getchar[link /reference/cstdio/getchar.md]
29-
* putchar[link /reference/cstdio/putchar.md]
30-
* puts[link /reference/cstdio/puts.md]
28+
* std::getchar[link /reference/cstdio/getchar.md]
29+
* std::putchar[link /reference/cstdio/putchar.md]
30+
* std::puts[link /reference/cstdio/puts.md]
3131

3232
### 入力
3333
```

reference/cstdio/fclose.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ namespace std {
2828
#include <cstdio>
2929
3030
int main() {
31-
FILE *fp = fopen("test.txt", "w");
32-
fclose(fp);
31+
std::FILE *fp = std::fopen("test.txt", "w");
32+
std::fclose(fp);
3333
}
3434
```
35-
* fclose[color ff0000]
36-
* fopen[link /reference/cstdio/fopen.md]
37-
* FILE[link /reference/cstdio/file.md]
35+
* std::fclose[color ff0000]
36+
* std::fopen[link /reference/cstdio/fopen.md]
37+
* std::FILE[link /reference/cstdio/file.md]
3838

3939
## 処理系
4040
- [Clang](/implementation.md#clang): ??

reference/cstdio/fgetc.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ namespace std {
2323
2424
int main() {
2525
int c;
26-
while ((c = fgetc(stdin)) != EOF) {
27-
putc(c, stdout);
26+
while ((c = std::fgetc(stdin)) != EOF) {
27+
std::putc(c, stdout);
2828
}
2929
}
3030
```
31-
* fgetc[color ff0000]
32-
* putc[link /reference/cstdio/putc.md]
31+
* std::fgetc[color ff0000]
32+
* std::putc[link /reference/cstdio/putc.md]
3333

3434
### 入力
3535
```

reference/cstdio/fgets.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ namespace std {
2525
2626
int main() {
2727
char str[10];
28-
fgets(str, sizeof(str), stdin);
29-
puts(str);
28+
std::fgets(str, sizeof(str), stdin);
29+
std::puts(str);
3030
}
3131
```
32-
* fgets[color ff0000]
33-
* puts[link /reference/cstdio/puts.md]
32+
* std::fgets[color ff0000]
33+
* std::puts[link /reference/cstdio/puts.md]
3434

3535
### 入力
3636
```

reference/cstdio/file.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* class[meta id-type]
55

66
```cpp
7-
typedef /* unspecified */ FILE;
7+
namespace std {
8+
typedef /* unspecified */ FILE;
9+
}
810
```
911
1012
## 概要

reference/cstdio/fopen.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ namespace std {
2424
#include <cstdio>
2525
2626
int main() {
27-
FILE *fp = fopen("test.txt", "w");
27+
std::FILE *fp = std::fopen("test.txt", "w");
2828
if (fp == NULL) {
29-
printf("ファイルを開けませんでした\n");
29+
std::printf("ファイルを開けませんでした\n");
3030
return 1;
3131
}
32-
fclose(fp);
32+
std::fclose(fp);
3333
return 0;
3434
}
3535
```
36-
* fopen[color ff0000]
37-
* fclose[link /reference/cstdio/fclose.md]
38-
* FILE[link /reference/cstdio/file.md]
39-
* printf[link /reference/cstdio/printf.md]
36+
* std::fopen[color ff0000]
37+
* std::fclose[link /reference/cstdio/fclose.md]
38+
* std::FILE[link /reference/cstdio/file.md]
39+
* std::printf[link /reference/cstdio/printf.md]
4040

4141
## 処理系
4242
- [Clang](/implementation.md#clang): ??

reference/cstdio/fputc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ namespace std {
2424
#include <cstdio>
2525
2626
int main() {
27-
fputc('a', stdout);
27+
std::fputc('a', stdout);
2828
}
2929
```
30-
* fputc[color ff0000]
30+
* std::fputc[color ff0000]
3131
* stdout[link /reference/cstdio/stdout.md]
3232

3333
### 出力

reference/cstdio/fputs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace std {
2020
#include <cstdio>
2121
2222
int main() {
23-
fputs("Hello, World!\n", stdout);
23+
std::fputs("Hello, World!\n", stdout);
2424
return 0;
2525
}
2626
```

reference/cstdio/getc.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* function[meta id-type]
55

66
```cpp
7-
int getc(FILE* stream);
7+
namespace std {
8+
int getc(FILE* stream);
9+
}
810
```
911
1012
## 概要
@@ -21,13 +23,13 @@ int getc(FILE* stream);
2123
2224
int main() {
2325
int c;
24-
while ((c = getc(stdin)) != EOF) {
25-
putc(c, stdout);
26+
while ((c = std::getc(stdin)) != EOF) {
27+
std::putc(c, stdout);
2628
}
2729
}
2830
```
29-
* getc[color ff0000]
30-
* putc[link /reference/cstdio/putc.md]
31+
* std::getc[color ff0000]
32+
* std::putc[link /reference/cstdio/putc.md]
3133

3234
### 入力
3335
```

reference/cstdio/getchar.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
* function[meta id-type]
55

66
```cpp
7-
int getchar();
7+
namespace std {
8+
int getchar();
9+
}
810
```
911
1012
## 概要
@@ -22,13 +24,13 @@ int getchar();
2224
#include <cstdio>
2325
int main() {
2426
int c;
25-
while ((c = getchar()) != EOF) {
26-
putchar(c);
27+
while ((c = std::getchar()) != EOF) {
28+
std::putchar(c);
2729
}
2830
}
2931
```
30-
* getchar[color ff0000]
31-
* putchar[link /reference/cstdio/putchar.md]
32+
* std::getchar[color ff0000]
33+
* std::putchar[link /reference/cstdio/putchar.md]
3234
* EOF[link /reference/cstdio/eof.md]
3335

3436
### 入力

0 commit comments

Comments
 (0)