Sign in to follow this  
KanonBaum

Xcode to Visual Studio

Recommended Posts

So I've recently tried porting my game from Mac (compiled under Xcode 4) to the Windows platform (compiled using Visual Studio 2008).

I eventually got it working fine, but upon execution, it crashes like never before. It turns out, there's some null memory being tossed around and bad iterator accessing data it shouldn't.
All of this was only discovered with a few minutes of debugging and I don't even know how many are actually there.

So, it pisses me off that Xcode and Mac did not detect these things (and some of them were just plain obvious). Now, I've told my small group of followers that the demo I was wrapping up is delayed yet again until I can track down all these bugs in Windows.

WHY. That sort of sloppy build-work shouldn't be allowed as a compiler. D: Is there any other reason for this?

Share this post


Link to post
Share on other sites
Code that is syntactically legal will usually get compiled without too many warnings from compilers. Most bugs can only be caught at runtime. Most compilers, in debug builds, will initialize variables to certain values. The value depends on the compiler and the object type. Anyway, sometimes the value is ok for your program, and you may have built it so it handled GCC's (Xcode's compiler) default initial values, but it wasn't built to handle Visual Studio's default values, hence you started to see the bugs. Or perhaps there weren't any default values in the Xcode debug builds, and the memory the objects were assigned to were filled with data that just happened to be what your program was expecting, but on the other computer this memory was not filled with the right data, hence you started to catch the bugs.

There's a few possibilities. Undefined behavior is a bi***.

Share this post


Link to post
Share on other sites
[quote name='KanonBaum' timestamp='1318868444' post='4873514']
So, it pisses me off that Xcode and Mac did not detect these things (and some of them were just plain obvious).
[/quote]
If the compiler is not required by the standard to issue a diagnostic, it may not. With that said, which compiler warnings did you enable when building with GCC? I recommend "-W -Wall -Werror" at a minimum.

[quote]That sort of sloppy build-work shouldn't be allowed as a compiler.[/quote]
When you start blaming the compiler, it's a slippery slope. Take this opportunity to learn from the experience. Visual C++ won't catch everything either (in fact it and GCC each catch different things, though there is a lot of overlap).

Trouble can be avoided to a large extent by adding asserts and tests. Though a compiler may add additional diagnostics to that which the standard requires, it shouldn't be [i]expected[/i].

The C family of languages (one of which I assume you are using) are brutal and unforgiving. If you're unable sustain the attention to detail required, you could perhaps try another language?

Share this post


Link to post
Share on other sites
[indent] On two occasions I have been asked,—"Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

—[url="http://en.wikipedia.org/wiki/Charles_Babbage"]Charles Babbage[/url], [i]Passages from the Life of a Philosopher[/i][sup][url="http://en.wikipedia.org/wiki/Garbage_In,_Garbage_Out#cite_note-1"][2][/url][/sup] [/indent]

Share this post


Link to post
Share on other sites
[quote name='edd'][color=#1C2837][size=2]If the compiler is not required by the standard to issue a diagnostic, it may not. With that said, which compiler warnings did you enable when building with GCC? I recommend "-W -Wall -Werror" at a minimum.[/size][/color][/quote]

Honestly, I'm not sure. I'll definitely note that. Thanks.

[color=#1C2837][size=2][quote name='edd']The C family of languages (one of which I assume you are using) are brutal and unforgiving. If you're unable sustain the attention to detail required, you could perhaps try another language?[/quote][/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[size="2"][color="#1c2837"]I am paying attention to detail as much as possible, which again, was why I become frustrated with it. It's not a small game. There's over thousands of lines of code in it and I've been working on it for a few years as it has grown. The library is portable, so the 'heavenly thought' would be I send it over to VS2008, maybe fix a few small bugs, and be done. Not literally crashing upon execution.

I suppose this post was primarily an unfair rant. [/color][/size]
[color=#1C2837][size=2]
[/size][/color][quote name='Antheus' timestamp='1318887148' post='4873641']
[indent] On two occasions I have been asked,—"Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

—[url="http://en.wikipedia.org/wiki/Charles_Babbage"]Charles Babbage[/url], [i]Passages from the Life of a Philosopher[/i][sup][url="http://en.wikipedia.org/wiki/Garbage_In,_Garbage_Out#cite_note-1"][2][/url][/sup] [/indent]
[/quote]

Cute quote, but I did not run about intentionally putting in wrong values. There's something wrong with the level-loading code. On Mac, everything runs just nifty. On Windows, it practically crashes on every new scene in a second flat. I haven't had the time since the other day to stop and look at it, but I was very mind-boggled over the whole scenario. A few bugs I was expecting, but not major routines (and the reason they say they are crashing); that is what frustrated me the most.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this