5 #include "sass/context.h"
7 int main( int argc, const char* argv[] )
10 // get the input file from first argument or use default
11 const char* input = argc > 1 ? argv[1] : "styles.scss";
13 // create the file context and get all related structs
14 struct Sass_File_Context* file_ctx = sass_make_file_context(input);
15 struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
16 struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
18 // configure some options ...
19 sass_option_set_precision(ctx_opt, 10);
21 // context is set up, call the compile step now
22 int status = sass_compile_file_context(file_ctx);
24 // print the result or the error to the stdout
25 if (status == 0) puts(sass_context_get_output_string(ctx));
26 else puts(sass_context_get_error_message(ctx));
28 // release allocated memory
29 sass_delete_file_context(file_ctx);
40 gcc -c main.c -o main.o
41 gcc -o sample main.o -lsass
42 echo "foo { margin: 21px * 2; }" > foo.scss
43 ./sample foo.scss => "foo { margin: 42px }"