Skip to content

ImportC: cannot include same .c files multiple times #23072

@Temtaime

Description

@Temtaime

a.c:#include <windows.h>
b.c:#include <windows.h>
test.d:import a, b;

The problem is, a and b can be different modules and many of C libraries use system headers.

winnt.h(2738): Error: struct `_SCOPE_TABLE_AMD64` already exists with an incompatible definition.
typedef struct _SCOPE_TABLE_AMD64 {
        ^
winnt.h(2738):        previously declared here
winnt.h(2745):        Field 1 differs in type
    } ScopeRecord[1];
      ^
winnt.h(2745):        typeof(ScopeRecord): __tag4132[1]
winnt.h(2745):        typeof(ScopeRecord): __tag5[1]
winnt.h(2738):        C structs with the same name from different imports are merged
typedef struct _SCOPE_TABLE_AMD64 {
        ^
winnt.h(4491): Error: struct `_SCOPE_TABLE_ARM` already exists with an incompatible definition.
typedef struct _SCOPE_TABLE_ARM {
        ^
winnt.h(4491):        previously declared here
winnt.h(4499):        Field 1 differs in type
    } ScopeRecord[1];
      ^
winnt.h(4499):        typeof(ScopeRecord): __tag4133[1]
winnt.h(4499):        typeof(ScopeRecord): __tag6[1]
winnt.h(4491):        C structs with the same name from different imports are merged
typedef struct _SCOPE_TABLE_ARM {
        ^
winnt.h(5342): Error: struct `_SCOPE_TABLE_ARM64` already exists with an incompatible definition.
typedef struct _SCOPE_TABLE_ARM64 {
        ^
winnt.h(5342):        previously declared here
winnt.h(5350):        Field 1 differs in type
    } ScopeRecord[1];
      ^
winnt.h(5350):        typeof(ScopeRecord): __tag4134[1]
winnt.h(5350):        typeof(ScopeRecord): __tag7[1]
winnt.h(5342):        C structs with the same name from different imports are merged
typedef struct _SCOPE_TABLE_ARM64 {
        ^
winioctl.h(11281): Error: struct `RETRIEVAL_POINTERS_BUFFER` already exists with an incompatible definition.
typedef struct RETRIEVAL_POINTERS_BUFFER {
        ^
winioctl.h(11281):        previously declared here
winioctl.h(11288):        Field 2 differs in type
    } Extents[1];
      ^
winioctl.h(11288):        typeof(Extents): __tag4262[1]
winioctl.h(11288):        typeof(Extents): __tag135[1]
winioctl.h(11281):        C structs with the same name from different imports are merged
typedef struct RETRIEVAL_POINTERS_BUFFER {
        ^
winioctl.h(11304): Error: struct `RETRIEVAL_POINTERS_AND_REFCOUNT_BUFFER` already exists with an incompatible definition.
typedef struct RETRIEVAL_POINTERS_AND_REFCOUNT_BUFFER {
        ^
winioctl.h(11304):        previously declared here
winioctl.h(11312):        Field 2 differs in type
    } Extents[1];
      ^
winioctl.h(11312):        typeof(Extents): __tag4263[1]
winioctl.h(11312):        typeof(Extents): __tag136[1]
winioctl.h(11304):        C structs with the same name from different imports are merged
typedef struct RETRIEVAL_POINTERS_AND_REFCOUNT_BUFFER {
        ^
winioctl.h(13822): Error: struct `_BOOT_AREA_INFO` already exists with an incompatible definition.
typedef struct _BOOT_AREA_INFO {
        ^
winioctl.h(13822):        previously declared here
winioctl.h(13827):        Field 1 differs in type
    } BootSectors[2];
      ^
winioctl.h(13827):        typeof(BootSectors): __tag4275[2]
winioctl.h(13827):        typeof(BootSectors): __tag148[2]
winioctl.h(13822):        C structs with the same name from different imports are merged
typedef struct _BOOT_AREA_INFO {
        ^
winioctl.h(15466): Error: union `(anonymous union)` already exists with an incompatible definition.
    union {
    ^
winioctl.h(15466):        previously declared here
winioctl.h(15459): Error: struct `_STREAM_EXTENT_ENTRY` already exists with an incompatible definition.
typedef struct _STREAM_EXTENT_ENTRY {
        ^
winioctl.h(15459):        previously declared here
winioctl.h(15475):        Field 1 differs in type
    } ExtentInformation;
      ^
winioctl.h(15475):        typeof(ExtentInformation): (anonymous union)
winioctl.h(15475):        typeof(ExtentInformation): (anonymous union)
winioctl.h(15459):        C structs with the same name from different imports are merged
typedef struct _STREAM_EXTENT_ENTRY {
        ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions