In ruby.h
, there are a lot of function macros defined like this:
static inline int
#if defined(HAVE_PROTOTYPES)
rb_type(VALUE obj)
#else
rb_type(obj)
VALUE obj;
#endif
{
if (FIXNUM_P(obj)) return T_FIXNUM;
if (obj == Qnil) return T_NIL;
if (obj == Qfalse) return T_FALSE;
if (obj == Qtrue) return T_TRUE;
if (obj == Qundef) return T_UNDEF;
if (SYMBOL_P(obj)) return T_SYMBOL;
return BUILTIN_TYPE(obj);
}
If HAVE_PROTOTYPES==1
, from my understanding, this function will be like this:
static inline int rb_type(VALUE obj)
{
...
}
Yet, if HAVE_PROPOTYPES==0
, the function definition will be like this:
static inline int rb_type(VALUE obj)
VALUE obj;
{
...
}
I don't understand if this is grammatically correct. How should I understand it?
static inline int rb_type(VALUE obj)
VALUE obj; # what the hack is this?
{
...
}
This is K&R C. Nobody uses it anymore. It has been deprecated for 20 years at least.
Long time ago function definitions were written like this:
int myfunc(myparam)
int myparam;
{
...
}
instead of
int myfunc(int myparam)
{
...
}
So HAVE_PROTOTYPES
will always be defined on any decent compiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With