tinycc-devel
[Top][All Lists]
Advanced

[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: Harry Yan
Subject: Re: [Tinycc-devel] TCC seems to be confused by a structure field: how should I fix this?
Date: Fri, 23 Dec 2022 08:29:57 +0800 (CST)

Hi gr,

Much appreciated for the detailed illustration. With your help I understood 
where the problem lies very quickly and perfectly, saving me lots of time of 
debugging. Now that this is solved, I could continue compiling this file with 
TCC.

Thanks a lot!
Harry




At 2022-12-22 21:24:26, "grischka" <grishka@gmx.de> wrote:
>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
>>
>
>
>_______________________________________________
>Tinycc-devel mailing list
>Tinycc-devel@nongnu.org
>https://lists.nongnu.org/mailman/listinfo/tinycc-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]