new qcc conflicts with system include files

785 views
Skip to first unread message

Федор Зуев

unread,
Jun 15, 2022, 3:48:37 AM6/15/22
to basilisk-fr

for example
file  test--include.c:
-----
#include <sys/stat.h>
int main(){}
------

attempt to compile:
-----
>qcc test-include.c
----
gives  following output:
----
/usr/include/x86_64-linux-gnu/sys/stat.h:206: warning: Basilisk C parse error near `const char *__restrict __file,
  struct stat *__restrict __buf'
/usr/include/x86_64-linux-gnu/sys/stat.h:225: warning: Basilisk C parse error near `const char *__restrict __file,
    struct stat64 *__restrict __buf'
/usr/include/x86_64-linux-gnu/sys/stat.h:235: warning: Basilisk C parse error near `int __fd, const char *__restrict __file,
     struct stat *__restrict __buf, int __flag'
/usr/include/x86_64-linux-gnu/sys/stat.h:250: warning: Basilisk C parse error near `int __fd, const char *__restrict __file,
       struct stat64 *__restrict __buf, int __flag'
/usr/include/x86_64-linux-gnu/sys/stat.h:260: warning: Basilisk C parse error near `const char *__restrict __file,
   struct stat *__restrict __buf'
/usr/include/x86_64-linux-gnu/sys/stat.h:273: warning: Basilisk C parse error near `const char *__restrict __file,
     struct stat64 *__restrict __buf'
/usr/include/asm-generic/int-ll64.h:23: warning: Basilisk C parse error near `

# 1 "/usr/include/x86_64-linux-gnu/bits/statx.h" 1 3 4
# 31 "/usr/include/x86_64-linux-gnu/bits/statx.h" 3 4
# 1 "/usr/include/linux/stat.h" 1 3 4

# 1 "/usr/include/linux/types.h" 1 3 4

# 1 "/usr/include/x86_64-linux-gnu/asm/types.h" 1 3 4
# 1 "/usr/include/asm-generic/types.h" 1 3 4 

# 1 "/usr/include/asm-generic/int-ll64.h" 1 3 4
# 12 "/usr/include/asm-generic/int-ll64.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/asm/bitsperlong.h" 1 3 4
# 11 "/usr/include/x86_64-linux-gnu/asm/bitsperlong.h" 3 4
# 1 "/usr/include/asm-generic/bitsperlong.h" 1 3 4
# 12 "/usr/include/x86_64-linux-gnu/asm/bitsperlong.h" 2 3 4
# 13 "/usr/include/asm-generic/int-ll64.h" 2 3 4

typedef __signed__ char __s8;
typedef unsigned char __u8;

typedef __signed__ short __s16'
/usr/include/asm-generic/int-ll64.h:30: warning: Basilisk C parse error near `

typedef __signed__ int __s32;
typedef unsigned int __u32;

__extension__ typedef __signed__ long long __s64'
/usr/include/asm-generic/int-ll64.h:31: warning: Basilisk C parse error near `
__extension__ typedef unsigned long long __u64'
/usr/include/linux/types.h:28: warning: Basilisk C parse error near `
typedef __u64 __le64'
/usr/include/linux/types.h:29: warning: Basilisk C parse error near `
typedef __u64 __be64'
/usr/include/linux/stat.h:59: warning: Basilisk C parse error near `
__s64 tv_sec;
__u32 tv_nsec;
__s32 __reserved;'
/usr/include/linux/stat.h:129: warning: Basilisk C parse error near `

__u32 stx_mask;
__u32 stx_blksize;
__u64 stx_attributes;

__u32 stx_nlink;
__u32 stx_uid;
__u32 stx_gid;
__u16 stx_mode;
__u16 __spare0[1];

__u64 stx_ino;
__u64 stx_size;
__u64 stx_blocks;
__u64 stx_attributes_mask;

struct statx_timestamp stx_atime;
struct statx_timestamp stx_btime;
struct statx_timestamp stx_ctime;
struct statx_timestamp stx_mtime;

__u32 stx_rdev_major;
__u32 stx_rdev_minor;
__u32 stx_dev_major;
__u32 stx_dev_minor;

__u64 stx_mnt_id;
__u64 __spare2;

__u64 __spare3[12];'
/usr/include/x86_64-linux-gnu/bits/statx-generic.h:61: warning: Basilisk C parse error near `int __dirfd, const char *__restrict __path, int __flags,
          unsigned int __mask, struct statx *__restrict __buf'
.qccQGDkfo/include-test.c:1:7: warning: line number out of range
include-test-cpp.c: warning: line number out of range
<built-in>: warning: line number out of range
/usr/include/stdc-predef.h:1:7: warning: line number out of range
/usr/include/x86_64-linux-gnu/bits/types.h:155:34: error: conflicting types for '__fsid_t'; have 'struct <anonymous>'
In file included from /usr/include/stdint.h:27,
                from /usr/lib/gcc/x86_64-linux-gnu/11/include/stdint.h:9,
                from include-test-cpp.c:6:
/usr/include/x86_64-linux-gnu/bits/types.h:155:26: note: previous declaration of '__fsid_t' with type '__fsid_t'
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:10:8: error: redefinition of 'struct timespec'
In file included from /usr/include/x86_64-linux-gnu/sys/select.h:39,
                from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                from /usr/include/stdlib.h:394,
                from /home/fedor/flood/basilisk-my/ast/std/stdlib.h:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h:10:8: note: originally defined here
----

Stephane Popinet

unread,
Jun 15, 2022, 3:07:43 PM6/15/22
to basil...@googlegroups.com
Hi Федор,

The system files you wish to use need to be "declared" in the qcc system
file hierarchy (in $BASILISK/ast/std/).

This is necessary because (low-level) system header files are often not
C99 conforming (e.g. the __restrict keyword in your example).

Note that this "declaration" is only necessary if the system header file
you wish to use is not C99 conforming.

Many system files are already included but not <sys/stat.h> (because it
is not used in any code within the main distribution).

To fix your problem you can do:

echo "@include <sys/stat.h>" > $BASILISK/ast/std/sys/stat.h

I will add it to the next release.

cheers,

Stephane


Vrionis Yiannis

unread,
Jul 29, 2022, 10:02:57 AM7/29/22
to basilisk-fr
Hello, 

I am getting a similar warning, which I was ignoring so far since everything was working fine.

I just saw this thread which seems relevant so I thought I could ask.

In detail, I see the same parse warning related to int16_t and uint8_t.
As far as I understand those are included in <stdint.h>, which is included in  $BASILISK/ast/std.

If you have any advice or suggestions please let me know.

Thanks,
Yiannis

Reply all
Reply to author
Forward
0 new messages