Skip to content

can't translate compound struct and union  #172

@1000copy

Description

@1000copy

On my Mac OS X 13.6, I have c language code which already compiled with compiler, like the piece:

// filename : main.c
typedef enum {asymbol,anumber}atom_type;
typedef struct sexpr_ sexpr;
typedef struct {
    atom_type type;
    union{
        char* a;
        double num;
    };
} atom;
typedef enum {slist,satom}sexpr_type;
typedef struct{
    int len;
    sexpr* a;
} list;
typedef struct sexpr_{
    sexpr_type type;
    union{
        list* list;
        atom* atom;
    };
}sexpr;
#include <stdio.h>
int main(){
    sexpr s = {.type = satom};
    printf("%d",s.type);

}

When I run cmd c2v main.c,A error occured:

error: inline comment is deprecated, please use line comment
   21 | fn main()  {
   22 |     s := Sexpr {
   23 |     /*FAILED TO FIND STRUCT "Sexpr"*/Sexpr_type.satom, }
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   24 |     
   25 |     C.printf(c'%d', s.type_)

What should I do next to solve the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions