From d87f42b0e53829052f17955ba1e17f938ae486fb Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 31 Mar 2021 00:45:43 +1100 Subject: examples/usercmodules: Simplify user C module enabling. It's a bit of a pitfall with user C modules that including them in the build does not automatically enable them. This commit changes the docs and examples for user C modules to encourage writers of user C modules to enable them unconditionally. This makes things simpler and covers most use cases. See discussion in issue #6960, and also #7086. Signed-off-by: Damien George --- examples/usercmodule/cppexample/examplemodule.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'examples/usercmodule/cppexample/examplemodule.c') diff --git a/examples/usercmodule/cppexample/examplemodule.c b/examples/usercmodule/cppexample/examplemodule.c index ceb588bef6..dfb7856837 100644 --- a/examples/usercmodule/cppexample/examplemodule.c +++ b/examples/usercmodule/cppexample/examplemodule.c @@ -22,4 +22,7 @@ const mp_obj_module_t cppexample_user_cmodule = { }; // Register the module to make it available in Python. -MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, MODULE_CPPEXAMPLE_ENABLED); +// Note: the "1" in the third argument means this module is always enabled. +// This "1" can be optionally replaced with a macro like MODULE_CPPEXAMPLE_ENABLED +// which can then be used to conditionally enable this module. +MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, 1); -- cgit v1.2.3