initializing to expressions

Dave Corcoran dave at aspect.UUCP
Tue Feb 12 04:48:16 AEST 1991


In article <91039.144030BRL102 at psuvm.psu.edu>, BRL102 at psuvm.psu.edu (Ben Liblit) writes:
> I want to initialize an array with values that are constant, but are in the
> form of expressions.  For example,
> 
>    double  value[ 2 ] = { sqrt( 2 ) / 2, cos ( sqrt( 5 ) ) };
> 
> Is there *any* way to convince my compiler (High C Compiler version 2, off of a

Well you said "any":
define(`bc_',`syscmd(echo "$'`1"| bc -l)')

double val[] = { bc_(sqrt(2) / 2), bc_(c(sqrt(5)))};
                                       ^^^^^^^^^^ ---- any valid bc(1) expr 
                                                       without commas
                                                       (they are interpreted
                                                       by m4 as arg separators)


I use trailing underscores to denote m4 macros.

This is as slow as mollasses through a funnel in January though.
-- 
David Corcoran		      -@@
uunet!aspect!dave	        ~
In a society where anything goes eventually everything will.



More information about the Comp.lang.c mailing list