Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,Monks

I'm using the Inline::C to integrate a SMS API. This set of API need to have a thread-safe callback function to response events.

Inside the callback function, if I use C "printf", the program crashes.If don't, using puts, the program works fine. The same c code works fine in Visual C++ compilers.

Any one could hilight me what happens? BTW I'm using Inline 0.44 and ActivePerl 5.8 build 804 on win32.

Thanks

Replies are listed 'Best First'.
Re: printf callback using Inline::C
by Abigail-II (Bishop) on Oct 07, 2003 at 15:06 UTC
    Very hard to say. It could be a bug in perl. It could be a bug in Inline::C. It could be a bug in your C code. It could be a bug in your C library. It could be a bug in your compiler. It could be a bug in the compiler used at ActiveState. It could be a bug in whatever SMS code you are linking with.

    Even if you show us the code, it'll be almost impossible to tell. You'd need the code and a stacktrace from a debugger for starters. And someone with time.

    Abigail

Re: printf callback using Inline::C
by PodMaster (Abbot) on Oct 07, 2003 at 15:06 UTC
    Don't use printf, use PerlIO_printf.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.