Код: Выделить всё
void foo(signed char x) {}
void foo(short x) {}
void foo(int x) {}
void foo(long x) {}
void foo(long long x) {}
void foo(int8_t x) {}
void foo(int16_t x) {}
void foo(int32_t x) {}
void foo(int64_t x) {}
Код: Выделить всё
:9:6: error: redefinition of 'void foo(int8_t)'
9 | void foo(int8_t x) {}
| ^~~
:4:6: note: 'void foo(signed char)' previously defined here
4 | void foo(signed char x) {}
| ^~~
:10:6: error: redefinition of 'void foo(int16_t)'
10 | void foo(int16_t x) {}
| ^~~
:5:6: note: 'void foo(short int)' previously defined here
5 | void foo(short x) {}
| ^~~
:11:6: error: redefinition of 'void foo(int32_t)'
11 | void foo(int32_t x) {}
| ^~~
:6:6: note: 'void foo(int)' previously defined here
6 | void foo(int x) {}
| ^~~
:12:6: error: redefinition of 'void foo(int64_t)'
12 | void foo(int64_t x) {}
| ^~~
:7:6: note: 'void foo(long int)' previously defined here
7 | void foo(long x) {}
| ^~~
< /code>
Если я напишу#include
void foo(int8_t x) {}
void foo(int16_t x) {}
void foo(int32_t x) {}
void foo(int64_t x) {}
int main() {
foo((signed char)1);
foo((short)1);
foo(1);
foo(1L);
foo(1LL);
}
Код: Выделить всё
: In function 'int main()':
:13:8: error: call of overloaded 'foo(long long int)' is ambiguous
13 | foo(1LL);
| ~~~^~~~~
:3:6: note: candidate: 'void foo(int8_t)'
3 | void foo(int8_t x) {}
| ^~~
:4:6: note: candidate: 'void foo(int16_t)'
4 | void foo(int16_t x) {}
| ^~~
:5:6: note: candidate: 'void foo(int32_t)'
5 | void foo(int32_t x) {}
| ^~~
:6:6: note: candidate: 'void foo(int64_t)'
6 | void foo(int64_t x) {}
| ^~~
< /code>
Если я напишу#include
void foo(signed char x) {}
void foo(short x) {}
void foo(int x) {}
void foo(long x) {}
void foo(long long x) {}
int main() {
foo((int8_t)1);
foo((int16_t)1);
foo((int32_t)1);
foo((int64_t)1);
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... defined-si