My C is rusty, but

If i saw

char *strcpy (char *dest, char *src)
I understand that strcopy takes pointers on the stack as its args. a web example shows
char input_str[20]; strcpy(input_str, "Hello");
so the prototype you gave of
extern void lcdCharDef(const int fd, int index, unsigned char data [8] +);
well unsigned char data [8] is not unsigned char *data. Does it mean the call stack has 8 characters in a row on it rather than a pointer to an array of 8 characters? if so your unsigned char * data in
void lcdCharDef(fd, index, data) int fd int index unsigned char * data
is putting a pointer to an array on the stack, isnt it?

i dug up my old C books, one copyright 1990 even, and i cant quite figure out what unsigned char data [8] in a prototype means, everytime char strings are passed the prototype is unsigned char *data

even looking on the web i dont see a prototype like unsigned char data [8], again all the calls seem to want unsigned char *data

edit,I researched and wrote this as other replys were coming in. So your workaround seems to imply that the pointer is what should be on the stack anyway, does that mean a prototype of unsigned char data [8] is converted to a prototype of unsigned char *data because of the [] array reference? what does the 8 do then?

edit2: ok, i should have hit the web harder, in most cases ive found a prototype of unsigned "something" data [8] uses some other type than char, like int. My first searches were for char arrays functions. In this case the 8 doesnt really mean anything and it is the same as unsigned char *data. If it were a 2d array or (N)d array they say all but the leftmost sizes need to be declared, even if you pass the array dims as parms. but void function_c(int m, int n, int arr[m][n]); is fine. this seems to be something introduced in C99, so i may need newer C books, 'cept i dont like to use it if i dont have to.


In reply to Re: External C function called through XS not Doing The Right Thing by huck
in thread [SOLVED (workaround)]: External C function called through XS not Doing The Right Thing by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.