Generated header files from configure_data being in quotes #12516
-
In one of my projects, various strings from the build time is included into a config header. Like a default user or group name. For exapmle; in meson_options.txt there is:
The needed output in the header file is:
Currently, the only way to achieve that I had to use some string formatting. But I can't help thinking there are better ways doing this. This is what I currently use:
Is this the only way to achieve this at the moment? Or are there better alternatives? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
build_cfg = configuration_data()
build_cfg.set_quoted(
'USERNAME', get_option('username'),
description: 'default username for the process',
) The set_quoted method is designed to handle the nitty-gritty of converting a string to something that the compiler treats as an appropriately defined string value. It also has an optional kwarg that adds a descriptive comment to the header file (autotools' autoheader does something similar). This doesn't work as an inlined value. You need to build the configuration object and then use the utility setters. |
Beta Was this translation helpful? Give feedback.
The set_quoted method is designed to handle the nitty-gritty of converting a string to something that the compiler treats as an appropriately defined string value. It also has an optional kwarg that adds a descriptive comment to the header file (autotools' autoheader does something similar).
This doesn't work as an inlined value. You need to build the configuration object and then use the utility setters.