pointer to printf causes triple fault?!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
carbonBased

pointer to printf causes triple fault?!

Post 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
anton

RE:pointer to printf causes triple fault?!

Post 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.
carbonBased

RE:pointer to printf causes triple fault?!

Post 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
Post Reply