Am 17.06.21 um 15:34 schrieb Stefan Seyfried:
I'm trying to update bluez to 5.59 and run across these errors when building with Leap 15.2/3's gcc-7:
tools/mesh-cfgtest.c:131:10: error: initializer element is not constant .path = cli_app_path, ^~~~~~~~~~~~ tools/mesh-cfgtest.c:131:10: note: (near initialization for 'client_app.path') tools/mesh-cfgtest.c:132:16: error: initializer element is not constant .agent_path = cli_agent_path, ^~~~~~~~~~~~~~ tools/mesh-cfgtest.c:132:16: note: (near initialization for 'client_app.agent_path') tools/mesh-cfgtest.c:140:12: error: initializer element is not constant .path = cli_ele_path_00, ^~~~~~~~~~~~~~~
This is the code in question: ---------------------------------------------------- static const char *dbus_err_args = "org.freedesktop.DBus.Error.InvalidArgs"; static const char *const cli_app_path = "/mesh/cfgtest/client"; static const char *const cli_agent_path = "/mesh/cfgtest/client/agent"; static const char *const cli_ele_path_00 = "/mesh/cfgtest/client/ele0"; static const char *const srv_app_path = "/mesh/cfgtest/server"; static const char *const srv_agent_path = "/mesh/cfgtest/server/agent"; static const char *const srv_ele_path_00 = "/mesh/cfgtest/server/ele0"; static const char *const srv_ele_path_01 = "/mesh/cfgtest/server/ele1";
static struct meshcfg_app client_app = { .path = cli_app_path, .agent_path = cli_agent_path, .cid = 0x05f1, .pid = 0x0002, .vid = 0x0001, .crpl = MAX_CRPL_SIZE, .num_ele = 1, .ele = { { .path = cli_ele_path_00, .index = PRIMARY_ELE_IDX, .mods = {CFG_SRV_MODEL, CFG_CLI_MODEL}, .vmods = {0xffffffff, 0xffffffff} } } }; ------------------------------------------------ for my untrained eye cli_app_path, cli_agent_path and cli_ele_path_00 look perfectly const. But what do I know?
Might be <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69960>. GCC 7 only supports C11, and there it seems string literals are not considered constant expressions. (Comment 9 on the bug.) C is a lot more restrictive than C++ when it comes to that stuff, see e.g. <http://c-faq.com/ansi/constasconst.html>. Adding Richard and Martin because I have only passing knowledge of C. Best regards, Aaron