Mantis - Squeak
Viewing Issue Advanced Details
7238 VM minor always 12-01-08 23:44 12-01-08 23:46
lewis  
lewis  
low  
assigned  
open  
none    
none  
0007238: SmartSyntaxPluginTMethod>>nullReturnExpr relies on #define null, may conflict with other libraries
In Cross/vm/sq.h we have:
#define null 0 /* using "null" because nil is predefined in Think C */

This is used as a return value in #nullReturnExpr, and presumably elsewhere.
However, this definition has been reported to conflict with other code bases, as reported by:
http://lists.squeakfoundation.org/pipermail/vm-dev/2008-October/002053.html [^]

Some value other than 'null' (e.g. 'sqNull') might prevent this problem.
From the vm-dev list (estebanlm at gmail.com):
Hi,
I had to change null output for squeak generated plugins (it was
colliding with other libraries needed) and I found this:

SmartSyntaxPluginTMethod>>nullReturnExpr
    ^ TReturnNode new
        setExpression: (TVariableNode new setName: 'null')


this generates correct return lines, but just because "null" is defined
previously. If I change null to, e.g. sqNil, the previous method still
generates "return null" lines.
So I changed the method as follows:

SmartSyntaxPluginTMethod>>nullReturnExpr
    ^ TReturnNode new
        setExpression: (TVariableNode new setName: 'nil')

just replaced "null" for "nil", and everything seems to be working
fine. Is this hack correct?

Cheers,
Esteban

There are no notes attached to this issue.