[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] TCC seems to be confused by a structure field: how sh
From: |
grischka |
Subject: |
Re: [Tinycc-devel] TCC seems to be confused by a structure field: how should I fix this? |
Date: |
Thu, 22 Dec 2022 14:24:26 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
On 22.12.2022 09:20, Harry Yan wrote:
Hello,
I am trying to build the SQLite3 command-line tool with TCC.
It works well with GCC:
$ gcc -c shell.c dirent.c
(no complaints)
However, TCC seems to be confused by a structure field:
Hi, yes, seems, but is not in that case.
Instead in that 'shell.c' we can find this:
149: # define DIRENT dirent
and
1421: # define DIRENT dirent
and
4737: # define dirent DIRENT
which now looks more like a good reason for us to be confused.
Using the compiler to help out
$ tcc -E -P shell.c -o shell.i
at 1250 we find:
struct DIRENT *pEntry = readdir(pLvl->pDir);
if( pEntry ){
if( pEntry->d_name[0]=='.' ){
So, tcc saying
"error: field not found: d_name"
is a correct statement because a 'struct DIRENT' or any members
of it were not defined anywhere.
I would agree however that a better message would be something more
similar to gcc in such case, for example:
"error: dereferencing incomplete type 'DIRENT'
As to your problem, it looks like that you need to make some decision
to the effect that either 'DIRENT' gets defined or that 'dirent' stays
undefined, as you may find appropriate.
-- gr
$ tcc -c shell.c dirent.c
shell.c:5359: error: field not found: d_name
Where line 5359 refers a d->name field from a dirent structure, which should be
the problem.
5355 while( pCur->iLvl>=0 ){
5356 FsdirLevel *pLvl = &pCur->aLvl[pCur->iLvl];
5357 struct dirent *pEntry = readdir(pLvl->pDir);
5358 if( pEntry ){
5359 if( pEntry->d_name[0]=='.' ){
5360 if( pEntry->d_name[1]=='.' && pEntry->d_name[2]=='\0' ) continue;
5361 if( pEntry->d_name[1]=='\0' ) continue;
5362 }
5363 sqlite3_free(pCur->zPath);
5364 pCur->zPath = sqlite3_mprintf("%s/%s", pLvl->zDir, pEntry->d_name);
5365 if( pCur->zPath==0 ) return SQLITE_NOMEM;
5366 if( fileLinkStat(pCur->zPath, &pCur->sStat) ){
5367 fsdirSetErrmsg(pCur, "cannot stat file: %s", pCur->zPath);
5368 return SQLITE_ERROR;
5369 }
5370 return SQLITE_OK;
5371 }
My TCC version is 0.9.27, which should be the latest. I am on the Windows
system.
I have attached the files in a zip so that it would be easy to test.
Thank you all for the help,
Harry
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel