Excerpts from the mail message of Billy Patton:
) 
) in my c code i have defined
) #define A 1
) #define B 2
) ....
) 
) How/where can I put this in my xs to get the same
) names in perl?
) 
) Can I
) &x(A,...);

My favorite method is wrapped up in lots of other code but just
extracting the simplest parts you can use:

BOOT:
    {
        HV *mHvStash= gv_stashpv( "My::Module::Name", TRUE );
        SV *mpSvNew;
        const2perl( A );
        const2perl( B );
    }

with

#define const2perl( const )     do {                                    \
        if(  const < 0  ) {                                             \
            newconst( #const, newSViv((IV)const) );                     \
        } else {                                                        \
            setuv( (UV)const );                                         \
            newconst( #const, mpSvNew );                                \
        }                                                               \
    } while( 0 )

#define newconst( sName, newSV )   newCONSTSUB( mHvStash, sName, newSV )

#define setuv(u)       do {                             \
        mpSvNew= newSViv(0); sv_setuv(mpSvNew,u);       \
    } while( 0 )

[BTW, I wish Perl's sv_setuv() returned the SV* that I passed to it.]

Tye

Reply via email to