This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
CORRECTED: Is there a '__builtin_compiletime_error' function of some sort?
- From: Ziemowit Laski <zlaski at apple dot com>
- To: gcc list <gcc at gcc dot gnu dot org>
- Date: Thu, 8 Jan 2004 21:12:13 -0800
- Subject: 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