Page 1 of 1

pointer to printf causes triple fault?!

Posted: Sun Sep 01, 2002 11:00 pm
by carbonBased
Here's a strange one:

Initially I had:
void printf(const char *format, ...);

Now I want to be able to redefine the main printing method (long story), so I've got:
void kprintf(const char *format, ...); // used to be just printf
void (*printf)(const char *format, ...) = *kprintf;

And... now I've got a triple fault on my hands.  This makes no sense to me.  Is there some subtle problem with pointers to functions containing ellipsis?

Or... I just thought of this... perhaps could gcc be making an assumption about printf?  In other words, it thinks it's defined as it would be in libc?

Thanks,
Jeff

RE:pointer to printf causes triple fault?!

Posted: Tue Sep 03, 2002 11:00 pm
by anton
where do you have the line
void (*printf)(const char *format, ...) = *kprintf;
Is it is in global space?(outside of any functions).
If it is then you should call a init for the global data or initialize it your self.
anton.

RE:pointer to printf causes triple fault?!

Posted: Tue Sep 03, 2002 11:00 pm
by carbonBased
Sorry, I meant to tell everybody I'd figured it out.

Rather odd, actually, GCC was compiling the call to printf without actually reading its prototype (ergo, assuming it was a regular function call, and not a function pointer call).

Essentially, all I had to do was include console.h in all files that used printf (something I thought I'd already done, seeing as though I got no error messages about unknown prototype).

Cheers,
Jeff