Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Request: In foo_sample, use the bogoSettings in another source file (Read 1342 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Request: In foo_sample, use the bogoSettings in another source file

foo_sample/preferences.cpp demonstrates how cfg_vars come to exist, but there doesn't seem to be any sample code for actually using them to do something outside of the preferences page. This could be a simple text output somewhere, or it could change the behaviour of one of the other sample elements (for example: change the min/max sizes in ui_element_dialog), as an actual setting would.

Motivation/Sob story: I've been working on a pretty basic component and failing to properly use the cfg_var derivatives. I was copying off consulting the source code of foo_dop, which uses the extern keyword in a header file to make these variables available in other classes, but that clashes with the documentation in cfg_var.h: "Note that cfg_var class and its derivatives may be only instantiated statically". A best practice example in the sample project would help me out immensely.

Re: Request: In foo_sample, use the bogoSettings in another source file

Reply #1
Static instantiation does not need to mean that they must be declared "static", just that they must be declared at a global scope, so they are statically instantiated on component load, and destroyed on shutdown. Feel free to remove the "static" keyword, just remember to always declare them at a global scope.