Brian Ingerson wrote:

> > Does Inline filter C source files through the C preprocessor?  When I try to
> > use #define to create a macro, or use #ifdef to turn off lines of source
> > code, there seems to be no effect.  Can anyone explain if this is the
> > expected behavior for Inline, or whether it is indeed a bug?
> 
> You can think of it this way.
> 
> 1) Raw Inline C code
> 2) Inline parses for function definitions
> 3) Add AUTOINCLUDE headers.
> 4) Generate XS file with above code and XS in same file.
> 5) Start build process.
>   A) xsubpp turns XS into pure C.
>   B) Normal C compile including preprocessing.
> 
> If you were hoping to have preprocessing happen between 1 & 2, check out
> Neil Watkiss' Inline::Filters.

One of my Inline-using modules has a C subroutine which was created from a
FORTRAN source file using f2c.  The FORTRAN code used the builtin function
AMAX1, which f2c converts to a macro called MAX.  The C code produced then
has lines like this:

#define max(a,b) ((a) >= (b) ? (a) : (b))
r = max(dpcp[1],dpcp[2]);   # This is equivalent to r =
AMAX1(dpcp(1),dpcp(2)) in FORTRAN

If Inline parses for function definitions in step (2), then it apparently
does not run the preprocessor before it gets to the max() line (above),
and thinks that max is a function, not a macro.  This is counter to what 
I would expect when writing C code for Inline, and was causing link errors
before I discovered the problem.

I'll take a look at Inline::Filters some time.

Thanks,

Brett



-- 
 Brett W. Denner                    Lockheed Martin Aeronautics Co.
 email: [EMAIL PROTECTED]     PO Box 748, MZ 9332
 phone: 817-935-1144                Fort Worth, TX 76101
 fax:   817-935-1212

Reply via email to