Pliant forum message

Concerning release: 33
Subject: Question
Title: A Char quickie
initial message posted by John Eikenberry on 2000/03/16 13:30:04
When calling an external function that takes a single char as an argument...

extern void SLsmg_write_char (char);

Is there anything special that needs to be done. Here's what I currently have:

function slsmg_write_char ch
  arg Char ch
  external slib "SLsmg_write_char"

But this spits out a random character when called. Usually some strange control

I've tried various things, like passing in an address, a single length string,
plus a few others. But with no luck. 

Any tips. Thanks.
answer posted by Hubert Tonneau on 2000/03/16 13:52:34
In Pliant, a 'Char' data is not an atomic data because it's size is not
the same as an 'Int'. As a result, it's always passed by address.
Use something like this:

function my_slsmg_write_char chnum
   arg Int chnum
   external slib "SLsmg_write_char"

function slsmg_write_char ch
   arg Char ch
   my_slsmg_write_char ch:number

If you don't like it, you have to define 'CChar', just as I did for 'CStr'.
Should be somethink like this, also I did not test it:

type CChar
  field Int number

function 'cast CChar' c -> cc
  arg Char c ; arg CChar cc
  cc number := c number

function 'cast Char' cc -> cc
  arg CChar cc ; arg Char c
  c := character cc:number
answer posted by John Eikenberry on 2000/03/16 14:33:50
Great... I knew it'd be something fairly simple. Thanks for the help.