Conditional Compilation Straddling Function Definitions

kravlor
kravlor's picture
Posts: 13
Joined: 2009-04-20
Location: United States

IP Manual:

Conditionals must be either completely outside or completely inside function definitions; they cannot straddle a function definition.

I would appreciate the ability to have conditional compilation straddle function definitions.

Motivation: I am in the process of debugging a large codebase of interdependent ThreadSafe functions. It would be very handy to be able to remove the ThreadSafe declaration from them all with a #define setting, enabling the Igor debugger.

Example code using wished-for feature:

#define USETHREADSAFE 
 
#if USETHREADSAFE
ThreadSafe Function myFunc(var, str)
#else
Function myFunc(var, str)
#endif
   Variable var
   String str
   // Function body
End

I'm sure others could come up with more clever uses, too.


JimProuty's picture
Posts: 180
Joined: 2007-07-19
Location: United States

There's no harm in leaving a function marked Threadsafe; you can still call it from a non-Threadsafe routine.

As far as conditional compilation straddling function definitions, I can see it being useful, but it would come at a cost: development time that could be better spent elsewhere.

--Jim Prouty
Software Engineer, WaveMetrics, Inc.


Back to top