in reply to Re^3: Help with Inline C
in thread Help with Inline C

I have noticed that some quoted strings in my code "\r\n" are being translated to (to a return and newline) in the corresponding XS file. this is whats creating some errors- now i have some mis-formed lines! is there a way to avoid ths?

Replies are listed 'Best First'.
Re^5: Help with Inline C
by mwah (Hermit) on Oct 15, 2007 at 15:55 UTC
    downer
    I have noticed that some quoted strings in my code "\r\n" are being translated to (to a return and newline) in the corresponding XS file.

    When I write Inline-C stuff, I have to add an extra escape to the backslashes:

    ... char string [] = "Hello World\\n"; ...

    Regards

    mwa

Re^5: Help with Inline C
by syphilis (Archbishop) on Oct 15, 2007 at 23:01 UTC
    now i have some mis-formed lines

    I have not struck this problem before (though it seems mwah has). Do you mean that the following simple Inline::C function leads to a corrupted XS file:
    void greet() { printf("Hello World\n"); }
    If not, then can you provide a *small* complete script that demonstrates the issue.

    Cheers,
    Rob
    Update:I hadn't noticed the OP's usage of <<END_C and wasn't aware of the gotcha (explained below by tye) associated with that usage.

      <<END_C is the same as <<"END_C" which means one needs to put a backslash in front of any occurrences of \, $, or @ in the following C code. If he used <<'END_C' instead, then he wouldn't have that problem.

      - tye