This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

CORRECTED: Is there a '__builtin_compiletime_error' function of some sort?


And if not, would there be objections if I were to add one in?

What I need is something like the following:

void __builtin_compiletime_error (const char *msg) {
  error (msg);  // <=== gcc's error routine
}

Of course, I don't want every single compile to fail :-); rather, I'd want to use __builtin_compiletime_error () in conjunction with __builtin_choose_expr () and
__builtin_types_compatible_p () to perform el cheapo function overloading in C, e.g.:


#define func(a) \
__builtin_choose_expr (__builtin_types_compatible_p (typeof (a), int), \
((int) func_int (a)), \
__builtin_choose_expr (__builtin_types_compatible_p (typeof (a), float), \
((float) func_float (a)), \
__bultin_compiletime_error ("no version of function 'func' matches parameter list")))



Does this sound like a reasonable plan of attack?


Thanks in advance,

--Zem


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]