Skip to main content
Topic: Request: In foo_sample, use the bogoSettings in another source file (Read 138 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.

 
SimplePortal 1.0.0 RC1 © 2008-2019