[plt-scheme] mzc question

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Mar 3 07:55:22 EST 2008

At Sun, 02 Mar 2008 20:46:19 -0500, tom sgouros wrote:
> $ make
> mzc --xform sserial.c
> mzc v370 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
> Error [CALL] 550 in sserial.c: Bad place for function call, starting tok
> is scheme_char_string_to_byte_string.
> xform: Errors converting

As Chongkai quoted in the manual, the problem is that a function call
is nested in some expression that's too complex for xform's approximate
parsing of C.

> The offending piece of code is this:
> 
>     if (SCHEME_CHAR_STRINGP(argv[1])) {
>       printf("Waiting to start: %s\n",
>            SCHEME_BYTE_STR_VAL(scheme_char_string_to_byte_string(argv[1])));

The solution is typically to lift out a function call and bind it to a
temporary variable:

     if (SCHEME_CHAR_STRINGP(argv[1])) {
       Scheme_Object *str;
       str = scheme_char_string_to_byte_string(argv[1]);
       printf("Waiting to start: %s\n",
            SCHEME_BYTE_STR_VAL(str));

Matthew



Posted on the users mailing list.