Re: gcc c++ vs. visual c++ info?
Re: gcc c++ vs. visual c++ info?
- Subject: Re: gcc c++ vs. visual c++ info?
- From: Thomas Dibble <email@hidden>
- Date: Sun, 23 Jan 2005 17:43:19 -0800
On Jan 23, 2005, at 6:31 AM, Dirk Stegemann wrote:
Hi,
Am 13.01.2005 um 17:17 schrieb james tittle:
...I've recently been asked to port some windoze code to osx, and
fairly quickly got it to compile, but then realized that all kinds of
weird things are going on incorrectly...
Am 13.01.2005 um 18:32 schrieb Thomas Dibble:
Other things to look at: any cross-platform libraries you are using
might have problems, any bit-shifting you are doing might cause
problems, any assumptions about static initializers might cause
problems ...
I've run into similar problems due to making VC++ code compile/run
with gcc3.3; actually, the code run already fine with gcc2.95, but
after updating to use gcc3.3, I encountered crashes at runtime.
I localized the crashes so far as they seem to occur in the
constructors of some standard-c-library functions, especially
"ifstream" and "ofstream".
Are there known issues with using these classes?
Are you using 10.2 SDKs? If so, you will need to include the gcc c++
header paths for those SDKs to the command line. If you don't, then
practically all c++ stream classes will send a SIGBUS the first time
they are used when the optimization level is above "0". In other
words, exactly what you're describing.
Specifically, this is what I had to add to my command line (via the
XCode Header Search Paths setting) which corrected the crashing
completely:
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/ppc-
darwin
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/
backward -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include
Obviously, change that list as needed if you are using the older 10.2.7
SDK instead of the 10.2.8 SDK.
The important information is here, that the code runs fine with
compiler optimization level set to -O0. Any other level produces code
that crashes.
Btw: There was one piece of code I was able to fix by replacing an
object's ifstream member function by an appropriate pointer,
initializing that pointer within the object's source code when used
for the first time by a call to "new ifstream".
Hmm. Interesting that that worked. However, fixing of the header
search paths should fix it in all cases.
---- Tom Dibble
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden