Re: What is the best way to define the Imported C function



On Jan 26, 5:31 pm, "Jeffrey R. Carter"
<spam.jrcarter....@xxxxxxxxxxxxxx> wrote:

I can't help you (and really, neither can those who have replied to you) because
the C specification isn't a specification; it doesn't tell us how the function
uses its parameters. Without that information, we can't tell how to interface to it.

The problem is that C uses the same construct for many conceptually different
things. For example:

void f (char* c);

may represent something that is conceptually equivalent to Ada's

procedure F (C : in Character); [unlikely, but possible]
procedure F (C : in out Character);
procedure F (C : out Character);
procedure F (C : in String);
procedure F (C : in out String);
procedure F (C : out String);

Given the common practice of using "char" to represent what Ada calls a
Storage_Element, and "char[]" or "char*" for Storage_Array, this single C
declaration may mean any of 12 different things.

It's probably worse than that, because even when char * refers to a
structure with multiple characters rather than a single character, you
don't know whether it's supposed to be a null-terminated string, or an
array of characters whose size is given somewhere else, or what.

-- Adam


.



Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)
  • Re: finding strings in a text file help
    ... digits and reserved words and then prints them out in order ... > it gets the whole string matches it against the reserved words array ... one character of a potential word in your "s" string. ... a char[] array would do. ...
    (comp.lang.java.help)