MERG-DEV / CBUS

Arduino library that implements a CBUS module
Other
1 stars 8 forks source link

Instantiating CBUSconfig object can fail to compile. #5

Open daveharrisuk opened 3 years ago

daveharrisuk commented 3 years ago

CBUSConfig config; // CBUS config object compiles ok. But... CBUSConfig CBUSconf; // CBUSconf object fails to compile.

The object 'config' is hard coded into CBUS.cpp as extern CBUSConfig config;

Reason this is an Issue: My app also has a 'config' object and want to make it clear which 'config' is which by changing both names.

Workaround: I'll change my app to use another object name and leave config name as is. Not ideal.

Dave Harris

SvenRosvall commented 2 years ago

Dave, There is an alternative solution for this if you really want to use your name "CBUSconf". Change your code like this:

CBUSConfig CBUSconf;
CBUS2515 cbus(&CBUSconf);

This creates the "cbus" object with the config that you want to use. Then there is no need for the external "config".

One reason we added this change was that there are some other Arduino libraries that use an external "config" object. As the two config objects have the same name, there is a conflict when compiling.

daveharrisuk commented 2 years ago

Hi Sven

That's good to know. Thanks for letting me know.

Dave

On Mon, 23 May 2022, 16:41 Sven Rosvall, @.***> wrote:

Dave, There is an alternative solution for this if you really want to use your name "CBUSconf". Change your code like this:

CBUSConfig CBUSconf; CBUS2515 cbus(&CBUSconf);

This creates the "cbus" object with the config that you want to use. Then there is no need for the external "config".

One reason we added this change was that there are some other Arduino libraries that use an external "config" object. As the two config objects have the same name, there is a conflict when compiling.

— Reply to this email directly, view it on GitHub https://github.com/MERG-DEV/CBUS/issues/5#issuecomment-1134834359, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOFEXFEDARGVDCQONE4TG3VLORLZANCNFSM4YQ7S3CQ . You are receiving this because you authored the thread.Message ID: @.***>