littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
5.18k stars 795 forks source link

IAR ARM compilation errors #437

Open sevstels opened 4 years ago

sevstels commented 4 years ago

disgusting code style...

Error[Pe144]: a value of type "void const *" cannot be used to initialize an entity of type "uint8_t const lfs_util.c 22

Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 30 Error[Pe513]: a value of type "void " cannot be assigned to an entity of type "uint32_t " \bd\lfs_testbd.c 39 Error[Pe513]: a value of type "void " cannot be assigned to an entity of type "uint32_t " \bd\lfs_testbd.c 41 Error[Pe029]: expected an expression \bd\lfs_testbd.c 53 Error[Pe029]: expected an expression \bd\lfs_testbd.c 60 Warning[Pe012]: parsing restarts here after previous syntax error \bd\lfs_testbd.c 63 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 89 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 108 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 118 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 128 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 137 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 151 Error[Pe020]: identifier "assert" is undefined \bd\lfs_testbd.c 154 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 176 Error[Pe020]: identifier "assert" is undefined \bd\lfs_testbd.c 179 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 222 Error[Pe020]: identifier "assert" is undefined \bd\lfs_testbd.c 225 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 279 Error[Pe020]: identifier "assert" is undefined \bd\lfs_testbd.c 282 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_testbd " \bd\lfs_testbd.c 292 Error[Pe020]: identifier "assert" is undefined \bd\lfs_testbd.c 295 Error while running C/C++ Compiler lfs_filebd.c
Warning[Pa050]: non-native end of line sequence detected (this diagnostic is only issued once) \bd\lfs_filebd.h 1 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_filebd " \bd\lfs_filebd.c 26 Error[Pe020]: identifier "O_RDWR" is undefined \bd\lfs_filebd.c 30 Error[Pe020]: identifier "O_CREAT" is undefined \bd\lfs_filebd.c 30 Error[Pe020]: identifier "open" is undefined \bd\lfs_filebd.c 30 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_filebd " \bd\lfs_filebd.c 60 Error[Pe020]: identifier "close" is undefined \bd\lfs_filebd.c 61 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_filebd " \bd\lfs_filebd.c 76 Error[Pe020]: identifier "assert" is undefined \bd\lfs_filebd.c 79 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 89 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 90 Error[Pe018]: expected a ")" \bd\lfs_filebd.c 90 Error[Pe020]: identifier "lseek" is undefined \bd\lfs_filebd.c 89 Error[Pe040]: expected an identifier \bd\lfs_filebd.c 90 Error[Pe020]: identifier "ssize_t" is undefined \bd\lfs_filebd.c 97 Error[Pe020]: identifier "read" is undefined \bd\lfs_filebd.c 97 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_filebd " \bd\lfs_filebd.c 112 Error[Pe020]: identifier "assert" is undefined \bd\lfs_filebd.c 115 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 121 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 122 Error[Pe018]: expected a ")" \bd\lfs_filebd.c 122 Error[Pe020]: identifier "lseek" is undefined \bd\lfs_filebd.c 121 Error[Pe040]: expected an identifier \bd\lfs_filebd.c 122 Error[Pe020]: identifier "ssize_t" is undefined \bd\lfs_filebd.c 131 Error[Pe020]: identifier "read" is undefined \bd\lfs_filebd.c 131 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 143 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 144 Error[Pe018]: expected a ")" \bd\lfs_filebd.c 144 Error[Pe020]: identifier "lseek" is undefined \bd\lfs_filebd.c 143 Error[Pe040]: expected an identifier \bd\lfs_filebd.c 144 Error[Pe020]: identifier "ssize_t" is undefined \bd\lfs_filebd.c 151 Error[Pe020]: identifier "write" is undefined \bd\lfs_filebd.c 151 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_filebd " \bd\lfs_filebd.c 164 Error[Pe020]: identifier "assert" is undefined \bd\lfs_filebd.c 167 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 171 Error[Pe020]: identifier "off_t" is undefined \bd\lfs_filebd.c 171 Error[Pe018]: expected a ")" \bd\lfs_filebd.c 171 Error[Pe020]: identifier "lseek" is undefined \bd\lfs_filebd.c 171 Error[Pe040]: expected an identifier \bd\lfs_filebd.c 171 Error[Pe020]: identifier "ssize_t" is undefined \bd\lfs_filebd.c 179 Error[Pe029]: expected an expression \bd\lfs_filebd.c 179 Error[Pe020]: identifier "write" is undefined \bd\lfs_filebd.c 179 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_filebd " \bd\lfs_filebd.c 195 Error[Pe020]: identifier "fsync" is undefined \bd\lfs_filebd.c 196 Error while running C/C++ Compiler lfs.c
Warning[Pa050]: non-native end of line sequence detected (this diagnostic is only issued once) \lfs.c 1 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "uint8_t " \lfs.c 31 Error[Pe020]: identifier "assert" is undefined \lfs.c 90 Error[Pe144]: a value of type "void const " cannot be used to initialize an entity of type "uint8_t const " \lfs.c 120 Error[Pe020]: identifier "assert" is undefined \lfs.c 142 Error[Pe020]: identifier "assert" is undefined \lfs.c 182 Error[Pe144]: a value of type "void const " cannot be used to initialize an entity of type "uint8_t const " \lfs.c 190 Error[Pe020]: identifier "assert" is undefined \lfs.c 191 Error[Pe020]: identifier "assert" is undefined \lfs.c 233 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 387 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 387 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 388 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 388 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 392 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 392 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 393 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 393 Warning[Pe224]: the format string requires additional arguments \lfs.c 495 Error[Pe018]: expected a ")" \lfs.c 494 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "uint8_t " \lfs.c 588 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "uint32_t " \lfs.c 647 Error[Pe167]: argument of type "void const " is incompatible with parameter of type "lfs_mdir const " \lfs.c 741 Error[Pe144]: a value of type "void const " cannot be used to initialize an entity of type "lfs_attr const " \lfs.c 751 Error[Pe029]: expected an expression \lfs.c 940 Warning[Pe224]: the format string requires additional arguments \lfs.c 998 Error[Pe018]: expected a ")" \lfs.c 997 Error[Pe070]: incomplete type is not allowed \lfs.c 1045 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_dir_find_match " \lfs.c 1070 Error[Pe144]: a value of type "void const " cannot be used to initialize an entity of type "lfs_diskoff const " \lfs.c 1072 Error[Pe029]: expected an expression \lfs.c 1172 Error[Pe144]: a value of type "void const " cannot be used to initialize an entity of type "lfs_diskoff const " \lfs.c 1241 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1403 Error[Pe029]: expected an expression \lfs.c 1403 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1403 Error[Pe029]: expected an expression \lfs.c 1403 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "uint32_t " \lfs.c 1447 Error[Pe144]: a value of type "void " cannot be used to initialize an entity of type "lfs_dir_commit_commit " \lfs.c 1460 Error[Pe119]: cast to type "unsigned int const [2]" is not allowed \lfs.c 1525 Error[Pe029]: expected an expression \lfs.c 1525 Warning[Pe224]: the format string requires additional arguments \lfs.c 1536 Error[Pe018]: expected a ")" \lfs.c 1536 Error[Pe029]: expected an expression \lfs.c 1606 Error[Pe020]: identifier "assert" is undefined \lfs.c 1667 Error[Pe029]: expected an expression \lfs.c 1673 Warning[Pe224]: the format string requires additional arguments \lfs.c 1685 Error[Pe018]: expected a ")" \lfs.c 1685 Error[Pe119]: cast to type "unsigned int const [2]" is not allowed \lfs.c 1689 Error[Pe029]: expected an expression \lfs.c 1689 Warning[Pe224]: the format string requires additional arguments \lfs.c 1691 Error[Pe018]: expected a ")" \lfs.c 1690 Warning[Pe224]: the format string requires additional arguments \lfs.c 1709 Error[Pe018]: expected a ")" \lfs.c 1707 Error[Pe020]: identifier "assert" is undefined \lfs.c 1746 Error[Pe029]: expected an expression \lfs.c 1792 Error[Pe020]: identifier "assert" is undefined \lfs.c 1840 Error[Pe029]: expected an expression \lfs.c 1845 Error[Pe144]: a value of type "lfs::lfs_mlist " cannot be used to initialize an entity of type "lfs_mlist " \lfs.c 1866 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1866 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1867 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1867 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1868 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1871 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1872 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1873 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1875 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1876 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1877 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1881 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1882 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1883 Error[Pe144]: a value of type "lfs::lfs_mlist " cannot be used to initialize an entity of type "lfs_mlist " \lfs.c 1891 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1891 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1892 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1893 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1893 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1893 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1895 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1895 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1896 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 1896 Error[Pe070]: incomplete type is not allowed \lfs.c 1918 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1955 Error[Pe029]: expected an expression \lfs.c 1955 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1955 Error[Pe029]: expected an expression \lfs.c 1955 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1977 Error[Pe029]: expected an expression \lfs.c 1977 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1977 Error[Pe029]: expected an expression \lfs.c 1977 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1992 Error[Pe029]: expected an expression \lfs.c 1992 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 1992 Error[Pe029]: expected an expression \lfs.c 1992 Error[Pe513]: a value of type "lfs_mlist " cannot be assigned to an entity of type "lfs::lfs_mlist " \lfs.c 2053 Error[Pe144]: a value of type "lfs::lfs_mlist " cannot be used to initialize an entity of type "lfs_mlist " \lfs.c 2062 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 2062 Error[Pe393]: pointer to incomplete class type is not allowed \lfs.c 2064 Error[Pe029]: expected an expression \lfs.c 2216 Warning[Pe224]: the format string requires additional arguments \lfs.c 2331 Error[Pe018]: expected a ")" \lfs.c 2331 Error[Pe029]: expected an expression \lfs.c 2346 Error[Pe513]: a value of type "lfs_mlist " cannot be assigned to an entity of type "lfs::lfs_mlist " \lfs.c 2418 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 2434 Error[Pe029]: expected an expression \lfs.c 2434 Error[Pe2363]: cast to incomplete array type "lfs_mattr []" is not allowed \lfs.c 2434 Error[Pe029]: expected an expression \lfs.c 2434 Error[Pe167]: argument of type "lfs_file::lfs_ctz " is incompatible with parameter of type "lfs_ctz " \lfs.c 2462 Error[Pe513]: a value of type "void " cannot be assigned to an entity of type "uint8_t " \lfs.c 2491 Error limit reached Error while running C/C++ Compiler

geky commented 4 years ago

I'm not really sure how to respond to this. Looking through a few of the warnings and the existing code is perfectly valid c99 code.

Are you sure you have IAR configured to compile in c99 mode? https://www.iar.com/support/resources/articles/exploring-c11-and-c14/

sevstels commented 4 years ago

If change the compilation mode, then the rest of the project wrong building. The principle "Either this or that".

I almost rework littlefs for C ++ without using macros. Macros are real Evil. But unfortunately I could not correctly replace macros:

LFS_MKATTRS LFS_MKTAG

with inline functions. If you can help me with this, then littlefs will build correctly in all cases.

For example like here:

/*

define LFS_MKATTRS(...) \

(struct lfs_mattr[]){__VA_ARGS__}, \
 sizeof((struct lfs_mattr[]){__VA_ARGS__}) / sizeof(struct lfs_mattr)      

*/

//============================================================= inline struct lfs_mattr LFS_MKATTRS( ...) { lfs_mattr attr = NULL; . . . . . . return attr; }

Thnk.

geky commented 4 years ago

Ah, unfortunately C++ is no longer a superset of C. As they bother developed they have diverged. I don't know the history there, but the version of C compatible with C++ (C89 I think?) lacks a lot of usability features (variables must be initialized at start of block, static, const, no C++ comments (//)), so I believe C99 is the best C standard to adopt at this time.

To combine C++/littlefs I would use two different compilation modes: gcc -std=c99 lfs.c -o lfs.o g++ -std=c++11 main.cpp -o main.o g++ lfs.o main.o -o app.elf

If change the compilation mode, then the rest of the project wrong building. The principle "Either this or that".

That sounds like an IDE/build system limitation. What IDE/build system are you using? Can it not handle .c and .cpp files differently?

I almost rework littlefs for C ++ without using macros. Macros are real Evil. But unfortunately I could not correctly replace macros:

LFS_MKATTRS LFS_MKTAG

LFS_MKATTRS creates an array on the stack which is used to pass a LISP-like list of commands to lfs_dir_commit. This is one case where an inline function won't work as it needs a variable number of arguments.

It does this using compound literals, another feature in C99 but not in C++. I think the closest you can get is to create a class using parameter pack, but I don't know exactly what it would look like: https://en.cppreference.com/w/cpp/language/parameter_pack

sevstels commented 4 years ago

I use IAR for ARM v8.32

For my taste, using macros on the stack makes the code unpredictable. This is why the project has so many error issues messages. The C ++ standard is specifically designed to improve the reliability of software. And practice shows us that the littlefs code is not reliable and not universal.

Later, I will probably complete a predictable stable version for C ++. When finished, I'll write a message here.

geky commented 3 years ago

A C++ port would be very interesting, at least to compare the two.