Re: stupid segfaults -- argh!



On 6/24/06, Paul Davis <paul linuxaudiosystems com> wrote:
On Sat, 2006-06-24 at 01:43 -0700, Joe Van Dyk wrote:
> On 6/24/06, Joe Van Dyk <joevandyk gmail com> wrote:
> > On 6/7/06, Joe Van Dyk <joevandyk gmail com> wrote:
> > > On 6/6/06, Paul Davis <paul linuxaudiosystems com> wrote:
> > > > On Mon, 2006-06-05 at 17:40 -0700, Joe Van Dyk wrote:
> > > > > I wonder why the documentation says a Gtk::Main object can't be
> > > > > created in the global scope.  Apparently, that's what I want to do, as
> > > > > I can't put it inside main().
> > > >
> > > > GTK and gtkmm require library initialization before any objects related
> > > > to them can be created. by attempting to put Gtk::Main in global scope
> > > > you are effectively asking for this order to be reversed.
> > >
> > > If I have Gtk::Main outside of any classes or functions (global scope,
> > > right?), what "related" objects would be created before Gtk::Main was
> > > called?
>
> Anyone?  I'm confused why having the call to Gtk::Main at file scope is bad.

a) it requires argc & argv to allow the user to pass in various GTK-
level options

Not an issue for me.  (I can't modify anything in main() as it's being
autogenerated by the build process)

b) you have essentially zero control over the ordering of it being
called relative to other globals.

Not an issue for me, as far as I know.  There aren't any other
gtk-related things at file scope.

c) putting things at file scope has been deprecated for, oh, about 20
years now. its just not something you do unless there is a very very
good reason to do so, and certainly not in an ostensibly object oriented
programming language.

Ok, thanks!  I guess not being able to put the call inside main()
might be a good reason.

Thanks,
Joe



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]