Re: passing NULL to a "char *" from tcl

William S Fulton <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <CANGqftCJz8io7GB=Lhd9xi2nQbNMvpAk4KwOrrkOrJa8j6nDZw@mail.gmail.com>
On Sat, 1 Feb 2020 at 08:34, Mihir Luthra <[email protected]>
wrote:

> Hi,
>
> First of all, I found swig yesterday and seriously, AMAZING! Especially
> that guide for truly lazy people for writing interface file. Thanks for the
> tool!
>
> I posted on the list to receive some help regarding using C functions in
> tcl.
> I have compiled and loaded all packages successfully.
>
> The point where I am stuck is that my function looks like this in C:
>
> bool abc(void *a, char *b);
>
> Doc [1] says to pass NULL from tcl, we should pass "NULL". I need to pass
> both
> arguments NULL.
>
> I do like:
>
> abc "NULL" "NULL"
>
> This works well for first argument. But second argument treats NULL as a
> string instead. Can anyone help me with this?
>
>
The idea with SWIG is it provides a default type mapping and you can change
this if you want some other behaviour. In this case, char * expects a
proper string. You could modify the char * typemap to accept a TCL NULL.
I'm not very familiar with Tcl, so I'm afraid I can't help with that,
you'll need to know the Tcl C API in order to support this. I suggest you
take a look at typemaps.

Regards
William

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.