Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C89: invalid use of incomplete type ‘struct lfs_disk_dir’ and other instances. #39

Open
kgillespieatmosphere opened this issue Mar 16, 2018 · 2 comments

Comments

@kgillespieatmosphere
Copy link

I am attempting to utilize littlefs in my project, but it seems there are times when incomplete struct types are being used. The problem is they're being declared in a nested struct definition and apparently my flavor or version of embedded GCC tool chain isn't too happy about it. The fix is fairly simple for example, to fix the mentioned issue above we can simply change the following,

typedef struct lfs_dir {
    struct lfs_dir *next;
    lfs_block_t pair[2];
    lfs_off_t off;

    lfs_block_t head[2];
    lfs_off_t pos;

    struct lfs_disk_dir {
        uint32_t rev;
        lfs_size_t size;
        lfs_block_t tail[2];
    } d;
} lfs_dir_t;

to

typedef struct lfs_disk_dir {
    uint32_t rev;
    lfs_size_t size;
    lfs_block_t tail[2];
} lfs_disk_dir_t;

typedef struct lfs_dir {
    struct lfs_dir *next;
    lfs_block_t pair[2];
    lfs_off_t off;

    lfs_block_t head[2];
    lfs_off_t pos;
    
    lfs_disk_dir_t d;
} lfs_dir_t;

And all is well. I am going to be doing this myself for my project, but would prefer to see it also applied upstream as well. There are several other places that this occurs and I can't see why declaring the structs this way would be an issue, though I could be missing something here. Let me know what you think.

@kgillespieatmosphere
Copy link
Author

I guess I could bundle all of my "issues" under the heading of C89 support.

@geky geky changed the title invalid use of incomplete type ‘struct lfs_disk_dir’ and other instances. C89: invalid use of incomplete type ‘struct lfs_disk_dir’ and other instances. Mar 17, 2018
@geky
Copy link
Member

geky commented Mar 17, 2018

Hi @kgillespieatmosphere, thanks for raising an issue.

Sorry, but littlefs is decidedly C99. Features such as designated initializers, inline functions, loop initializers, // comments, are just too convenient and heavily used in the library.

Out of curiosity, what environment are you in that prevents C99?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants