|
|
Up |
|
|
  |
Author: GaryScottGaryScott Date: Aug 30, 2008 11:30
I haven't checked, sorry. Does C interoperability provide assistance
for string interoperability? It would be nice if I didn't keep having
to write a "delete nulls" function to remove those annoying null
characters from C-returned strings (e.g. API error message text). It
isn't very difficult, but I'd prefer a nice "slick" method.
|
| |
|
| | 18 Comments |
|
  |
Author: Ron FordRon Ford Date: Aug 31, 2008 16:27
On Sat, 30 Aug 2008 11:30:41 -0700 (PDT), GaryScott posted:
> I haven't checked, sorry. Does C interoperability provide assistance
> for string interoperability? It would be nice if I didn't keep having
> to write a "delete nulls" function to remove those annoying null
> characters from C-returned strings (e.g. API error message text). It
> isn't very difficult, but I'd prefer a nice "slick" method.
Gary,
Are you aware of c_null_char? The code listing for 14.3 MR&C might be what
you're looking for.
--
We must be willing to pay a price for freedom. 4
H. L. Mencken
|
| |
|
| | no comments |
|
  |
Author: Gary ScottGary Scott Date: Aug 31, 2008 16:50
Ron Ford wrote:
> On Sat, 30 Aug 2008 11:30:41 -0700 (PDT), GaryScott posted:
>
>
>>I haven't checked, sorry. Does C interoperability provide assistance
>>for string interoperability? It would be nice if I didn't keep having
>>to write a "delete nulls" function to remove those annoying null
>>characters from C-returned strings (e.g. API error message text). It
>>isn't very difficult, but I'd prefer a nice "slick" method.
>
>
> Gary,
>
> Are you aware of c_null_char? The code listing for 14.3 MR&C might be what
> you're looking for.
|
| Show full article (1.90Kb) |
| no comments |
|
  |
Author: ianbush.throwaway.accountianbush.throwaway.account Date: Sep 1, 2008 01:13
On Aug 30, 7:30 pm, GaryScott sbcglobal.net> wrote:
> I haven't checked, sorry. Does C interoperability provide assistance
> for string interoperability? It would be nice if I didn't keep having
> to write a "delete nulls" function to remove those annoying null
> characters from C-returned strings (e.g. API error message text). It
> isn't very difficult, but I'd prefer a nice "slick" method.
No, there isn't an intrinsic way in the language to do this
conversion.
Also you are aware that to be interoperable Fortran Character
variables
must have Len = 1 ?
Ian
|
| |
| no comments |
|
  |
Author: Gary ScottGary Scott Date: Sep 1, 2008 07:58
> On Aug 30, 7:30 pm, GaryScott sbcglobal.net> wrote:
>
>>I haven't checked, sorry. Does C interoperability provide assistance
>>for string interoperability? It would be nice if I didn't keep having
>>to write a "delete nulls" function to remove those annoying null
>>characters from C-returned strings (e.g. API error message text). It
>>isn't very difficult, but I'd prefer a nice "slick" method.
>
>
> No, there isn't an intrinsic way in the language to do this
> conversion.
> Also you are aware that to be interoperable Fortran Character
> variables
> must have Len = 1 ?
|
| Show full article (1.31Kb) |
| no comments |
|
  |
Author: nospamnospam Date: Sep 1, 2008 10:04
Gary Scott sbcglobal.net> wrote:
>> Also you are aware that to be interoperable Fortran Character
>> variables must have Len = 1 ?
>
> No, I only use F95 compilers at present (CVF, LF95, Absoft F90) that
> interoperate with normal character buffers of whatever length as long as
> you insert a null character at the end of the trimmed length. Are you
> saying that I must use an array to designate a string? Boy that would
> be inconvenient.
No, that is *NOT* the implication, although Ian might well mistakenly
think so. That seems to be developing as a FAQ for the C interop stuff.
The developers of the standard aren't quite so dense as to not have
figured out how inconvenient that would be. That exact issue got very
specific attention during development. There is even a special-case rule
to facilitate it. (It turned out not to take too much of a special case,
but it did require one somewhat strange historical rule to be extended
from default character to also apply to character(kind=c-kind), even
though it doesn't apply to all character kinds).
|
| Show full article (2.34Kb) |
| no comments |
|
  |
Author: Ian BushIan Bush Date: Sep 1, 2008 23:55
On 1 Sep, 18:04, nos...@see.signature (Richard Maine) wrote:
> Gary Scott sbcglobal.net> wrote:
>>> Also you are aware that to be interoperable Fortran Character
>>> variables must have Len = 1 ?
>
>> No, I only use F95 compilers at present (CVF, LF95, Absoft F90) that
>> interoperate with normal character buffers of whatever length as long as
>> you insert a null character at the end of the trimmed length. Are you
>> saying that I must use an array to designate a string? Boy that would
>> be inconvenient.
>
> No, that is *NOT* the implication, although Ian might well mistakenly
> think so. That seems to be developing as a FAQ for the C interop stuff.
> The developers of the standard aren't quite so dense as to not have
> figured out how inconvenient that would be. That exact issue got very
> specific attention during development. There is even a special-case rule
> to facilitate it. (It turned out not to take too much of a special case,
> but it did require one somewhat strange historical rule to be extended
> from default character to also apply to character(kind=c-kind), even ...
|
| Show full article (2.92Kb) |
| no comments |
|
  |
Author: glen herrmannsfeldtglen herrmannsfeldt Date: Sep 3, 2008 11:31
Gary Scott wrote:
(snip)
> No, I only use F95 compilers at present (CVF, LF95, Absoft F90) that
> interoperate with normal character buffers of whatever length as long as
> you insert a null character at the end of the trimmed length. Are you
> saying that I must use an array to designate a string? Boy that would
> be inconvenient.
Note that null terminated strings aren't part of the C language,
but are used by some C library routines. There are many library
routines that will work just fine with strings without null
terminators. As in a previous post on sorting, there is
strncmp which will compare strings up to a specified length
(or to a null character if that comes first.) There is
also memcmp() to compare strings containing null characters.
-- glen
|
| |
| no comments |
|
  |
Author: Gary ScottGary Scott Date: Sep 3, 2008 16:20
glen herrmannsfeldt wrote:
> Gary Scott wrote:
> (snip)
>
>> No, I only use F95 compilers at present (CVF, LF95, Absoft F90) that
>> interoperate with normal character buffers of whatever length as long
>> as you insert a null character at the end of the trimmed length. Are
>> you saying that I must use an array to designate a string? Boy that
>> would be inconvenient.
>
>
> Note that null terminated strings aren't part of the C language,
> but are used by some C library routines. There are many library
> routines that will work just fine with strings without null
> terminators. As in a previous post on sorting, there is
> strncmp which will compare strings up to a specified length
> (or to a null character if that comes first.) There is
> also memcmp() to compare strings containing...
|
| Show full article (1.32Kb) |
| no comments |
|
  |
|
|
  |
Author: glen herrmannsfeldtglen herrmannsfeldt Date: Sep 3, 2008 16:48
Gary Scott wrote:
(snip)
> :) I've yet to run across any C APIs that do not expect/return null
> termintors, but if I ever do, it won't surprise me as much.
See strncpy() in the standard C library.
-- glen
|
| |
| no comments |
|
|
|
|