[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] __LINE__ and #line undelying type
From: |
Christian Jullien |
Subject: |
Re: [Tinycc-devel] __LINE__ and #line undelying type |
Date: |
Fri, 16 Apr 2021 06:13:26 +0200 |
Hi,
C standard says:
_ _LINE_ _ The presumed line number (within the current source file) of the
current
source line (an integer constant).
So, it should be a signed integer (same as int on your running architecture
which is internally either int32_t or int64_t depending on how int is
represented).
For type safety, it is important that __LINE__ is an int because a lot of code
uses this type to call functions as below:
void debug(const char* file, int line, const char* msg) {
printf("%s(%d) %s\n", file, line msg);
}
gcc, clang and tcc all use an int as you can see below, so tcc looks right to
me:
jullien@sims4:~ $ more foo.c
#include <stdio.h>
#define TYPEOF(x) _Generic((x), \
char: "char", \
short: "short", \
int: "int", \
unsigned int: "unsigned int", \
long: "long", \
unsigned long: "unsigned long", \
long long: "long long", \
float: "float", \
double: "double", \
long double: "long double")
int
main() {
unsigned int k;
int i;
printf("__LINE__: %s\n", TYPEOF(__LINE__));
printf("unsigned: %s\n", TYPEOF(k));
printf("signed: %s\n", TYPEOF(i));
}
jullien@sims4:~ $ gcc -std=c11 foo.c -o foo && ./foo
__LINE__: int
unsigned: unsigned int
signed: int
jullien@sims4:~ $ clang -std=c11 foo.c -o foo && ./foo
__LINE__: int
unsigned: unsigned int
signed: int
jullien@sims4:~ $ tcc -std=c11 foo.c -o foo && ./foo
__LINE__: int
unsigned: unsigned int
signed: int
-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On
Behalf Of Yakov
Sent: Friday, April 16, 2021 03:18
To: Tinycc-devel@nongnu.org
Subject: [Tinycc-devel] __LINE__ and #line undelying type
I remember #line was limited to 65535 on tcc recently, but now it is
limited to 294967295 (max int32), when this was changed?
Also I think it should be 42949672965 instead (max uint32) as in GCC and Clang.
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
- [Tinycc-devel] __LINE__ and #line undelying type, Yakov, 2021/04/15
- Re: [Tinycc-devel] __LINE__ and #line undelying type,
Christian Jullien <=
- Re: [Tinycc-devel] __LINE__ and #line undelying type, Elijah Stone, 2021/04/16
- Re: [Tinycc-devel] __LINE__ and #line undelying type, Christian Jullien, 2021/04/16
- Re: [Tinycc-devel] __LINE__ and #line undelying type, Christian Jullien, 2021/04/16
- Re: [Tinycc-devel] __LINE__ and #line undelying type, Vincent Lefevre, 2021/04/16
- Re: [Tinycc-devel] __LINE__ and #line undelying type, Edmund Grimley Evans, 2021/04/16
- Re: [Tinycc-devel] __LINE__ and #line undelying type, Vincent Lefevre, 2021/04/16
- Re: [Tinycc-devel] __LINE__ and #line undelying type, Vincent Lefevre, 2021/04/16