6 #include "sass/values.h"
8 int main( int argc, const char* argv[] )
11 // create two new sass values to be added
12 union Sass_Value* string = sass_make_string("String");
13 union Sass_Value* number = sass_make_number(42, "nits");
15 // invoke the add operation which returns a new sass value
16 union Sass_Value* total = sass_value_op(ADD, string, number);
18 // no further use for the two operands
19 sass_delete_value(string);
20 sass_delete_value(number);
22 // this works since libsass will always return a
23 // string for add operations with a string as the
24 // left hand side. But you should never rely on it!
25 puts(sass_string_get_value(total));
27 // invoke stringification (uncompressed with precision of 5)
28 union Sass_Value* result = sass_value_stringify(total, false, 5);
30 // no further use for the sum
31 sass_delete_value(total);
33 // print the result - you may want to make
34 // sure result is indeed a string, altough
35 // stringify guarantees to return a string
36 // if (sass_value_is_string(result)) {}
37 // really depends on your level of paranoia
38 puts(sass_string_get_value(result));
40 // finally free result
41 sass_delete_value(result);
49 ## Compile operation.c
52 gcc -c operation.c -o operation.o
53 gcc -o operation operation.o -lsass
54 ./operation # => String42nits