Hello lucy-dev,
In the course of my work on the C bindings, I had to add functions to
Charmonizer::Core::Compiler that handle several flags needed to compile
and link the shared library. Also, some additional requirements popped up:
* We need a way to compile probes with a temporary set of
compiler flags.
* Besides appending compiler flags to the "extra" flags, we
sometimes have to create flags for other purposes. The API
for both these operations should be easy to use.
My current implementation is somewhat ad-hoc and I'm not really happy
with the result. I think it could be cleaned up by introducing a
separate "class" for compiler flags (and linker flags). It could be used
something like that:
chaz_CFlags *flags = chaz_CFlags_new();
chaz_CFlags_append(flags, "--some-option");
chaz_CFlags_set_feature_abc(flags, arg1);
chaz_CFlags_set_feature_xyz(flags, arg2);
const char *flag_string = chaz_CFlags_get_string(flags);
Then the chaz_CC struct would have the following fields with
corresponding accessors:
chaz_CFlags *extra_cflags;
chaz_CFlags *temp_cflags;
Using temporary flags would work like this:
chaz_CFlags *temp_flags = chaz_CC_get_temp_cflags();
chaz_CFlags_append(temp_flags, "--option");
chaz_CC_test_compile(...);
chaz_CFlags_clear(temp_flags);
What do you think?
Nick