rui314 / chibicc

A small C compiler
MIT License
9.57k stars 871 forks source link

FreeBSD stdarg support #21

Open ppenzin opened 3 years ago

ppenzin commented 3 years ago

FreeBSD gives out this rather excluding message when including stdio.h:

/usr/include/sys/_types.h:135: #error "No support for your compiler for stdargs"

It is triggered by is this condition in cdefs.h not being met (and the guarded macros not getting set):

#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3)
#define __GNUCLIKE_BUILTIN_VARARGS 1
#define __GNUCLIKE_BUILTIN_STDARG 1
#define __GNUCLIKE_BUILTIN_VAALIST 1
#endif
rui314 commented 3 years ago

I'll eventually define __GNUC__ macro, and I think that should fix this problem. I'm not doing it right now because it opens a can of warms. If you define __GNUC__, the stdlib headers expect that your compiler supports all GCC extensions, such as various kinds of __attribute__. So, I'll do that after the extensions are implemented.

ppenzin commented 3 years ago

Right, setting __GNUC __ yields this:

/usr/include/sys/cdefs.h:228: #define   __aligned(x)    __attribute__((__aligned__(x)))
                                                 ^ expected ','

Edit: I've tried setting a breakpoint at the point where that error should be produced, but did not realize chibicc relaunches itself at first.

qq528134537 commented 3 years ago

What do you use to write code? Is it a diary?