windelbouwman / ppci

A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
https://ppci.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
337 stars 36 forks source link

c parser crash in stdlib.h #129

Closed tekknolagi closed 2 years ago

tekknolagi commented 2 years ago

Hi,

Awesome project. I am trying to compile a C program. I ended up needing to specify a bunch of include directories (is this known?) and when I got ppci to find stdlib.h, it crashed:

2022-04-14 23:15:05,424 |     INFO |       root | ppci 0.5.8 on CPython 3.8.10 on Linux-5.13.0-39-generic-x86_64-with-glibc2.29
2022-04-14 23:15:05,427 |     INFO |   cbuilder | Starting C compilation (c99)
2022-04-14 23:15:05,635 |  WARNING |    cparser | No type given ((/usr/include/stdlib.h, 97, 8)), assuming int!
2022-04-14 23:15:05,635 |    ERROR |       root | Expected ";", got "ID"
2022-04-14 23:15:05,635 |    ERROR |       root | (/usr/include/stdlib.h, 97, 15)
File : "/usr/include/stdlib.h"
   95:/* Maximum length of a multibyte character in the current locale.  */
   96:#define   MB_CUR_MAX  (__ctype_get_mb_cur_max ())
   97:extern size_t __ctype_get_mb_cur_max (void) __THROW __wur;
                    ^ Expected ";", got "ID"
   98:
   99:
  100:/* Convert a string to a floating-point number.  */

I really appreciate the error styling.

tekknolagi commented 2 years ago

Ah, I see now that I am supposed to use the builtin librt. Sorry!