ninja kitty
Friday, December 5th, 2008I loled
I loled
I’ve been cruising along developing this app in Borland’s C++ Builder when I ran into the strangest stumbling block.
When I open an ofstream in the test application like so:
std::ofstream outFile(”foo.bar”);
everything works just duckiliciously.
However, when I execute the same line of code within the context of a gui app’s menu save event trigger, I get a huge explosion.
Over the last 45 minutes I’ve been back and forth, tracing it through and I’ve come down to a problem with the locale. the getloc() method in std::ios_base (which is just returning a dereferenced _Ploc) is crapping out all over the place, as if the default _Ctype doesn’t exist in the context of the gui app.
Is there some kind of standard library initialization that’s going on in the console app that isn’t going on in the gui? I’ve been pouring over the build and link options and everything SEEMS ok. But I have to be missing something.
“Oh yeah, development’s going great. I mean, aside from the fact that I can’t get it to SAVE” doesn’t work.
As a goof, here’s the stack:
std::ios_base::getloc(this=:0012FB48)
std::basic_ios>::widen(this=:0012FB48, _Byte=’ ‘)
std::basic_ios>::init(this=:0012FB48, _Strbuf=:0012FAF0, _Isstd=false)
std::basic_ostream>::basic_ostream >(this=:0012FAE8, _Strbuf=:0012FAF0, _Isstd=false)
std::basic_ofstream>::basic_ofstream >(this=:0012FAE8, _Filename=:004071F6, _Mode=2, _Prot=438)
UPDATE: Well I’ll never run in to this problem again, so I’ll put the answer here just in case I’m wrong about that too.
The call to the std::ofstream constructor in the gui app was taking place inside a dependent library that had options incompatible with the gui application itself, but not with the console application. So in one case it was using the correct (read: matched) ctype and locale information and in the other case it wasn’t.
Pulling it out of the library (where frankly it didn’t really belong anyway, I was prematurely optimizing) into the main project worked just duckiliciously.
I’ll bet you all were really worried huh?
I’d completely forgotten that, when taken right out of the microwave and eaten, Hot Pockets are little doughy envelopes of napalm.
I’m not going to be able to taste anything for a day and a half. S’pose I should use the opportunity to eat a bunch of broccoli or something.
Yeah.
Right.
For some reason, when I imported all the 3400 or so posts from the previous two incarnations of this blog the comment status was set to ‘closed’ on all the imported posts.
I just logged in to the WP database and ran some DML to open everything. So we’ll see what happens.
So, can someone tell me why Apple doesn’t make any kind of docking station for their mactops? I love the keyboard on the thing but I have a pathological hatred for trackpads, so much so that all I use this for is watching the market and writing while I’m sitting in bed.
It would be such a simple piece of hardware. You could even make it some sort of dongle thingie that plugged in to the right-side of the ‘top, since the dvi, 1384, usb and network plugs are all right there. I’m pretty sure some enterprising fabricator could bang something out that would serve the purpose. I, unfortunately have no idea what it takes to get something like that done.
I’d use it an awful lot more. Hell, I might even bias towards using this as my primary box.
I’m just sayin’ is all.