[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] global declaration behavior of TCC
From: |
Basile STARYNKEVITCH |
Subject: |
[Tinycc-devel] global declaration behavior of TCC |
Date: |
Wed, 23 Oct 2002 23:53:38 +0200 |
Sorry,
(I don't have my ISO99 C standard here so I might be wrong)
It seems that TCC don't handle correctly a declaration appearing
several times (because it is in an include file):
// file e1.c
#include "i.h"
int plusi(int x) { return i+x; };
// eof e1.c
// file e2.c
#include <stdio.h>
#include <stdlib.h>
#include "i.h"
int main(int argc, char**argv) {
int y=0;
if (argc>1) y=atoi(argv[1]);
if (argc>2) i=atoi(argv[2]);
printf("y=%d i=%d plusi(y)=%d\n",
y, i, plusi(y));
return 0;
}
// eof e2.c
// file i.h
int i;
// eof i.h
When compiling with tcc -o e e1.c e2.c I am getting:
In file included from e2.c:6:
i.h:3: 'i' defined twice
I think this behavior might not be correct. (and I know that C and C++
differs on these matters). At least gcc don't have it
I also suggest that TCC should swallow either silently or with a
warning any -O option (even if it does not do any additional
optimisation).
The following patch achieve this:
diff -Naur tcc.c.orig tcc.c
--- tcc.c.orig 2002-10-23 23:29:59.000000000 +0200
+++ tcc.c 2002-10-23 23:31:12.000000000 +0200
@@ -7526,7 +7526,9 @@
} else
#endif
if (r[1] == 'g') {
- do_debug = 1;
+ do_debug = 1;
+ } else if (r[1] == 'O') {
+ warning("ignoring optimisation %s\n", r);
} else if (r[1] == 'c') {
multiple_files = 1;
output_type = TCC_OUTPUT_OBJ;
If it matters my plateform is Debian/Linux unstable and TCC is version
0.9.12
regards.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net
alias: basile<at>tunes<dot>org
8, rue de la Faïencerie, 92340 Bourg La Reine, France
- [Tinycc-devel] global declaration behavior of TCC,
Basile STARYNKEVITCH <=