Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 24, 2012, 04:43 AM   #1
ClausW
macrumors newbie
 
Join Date: Mar 2012
new gcc no longer works properly(gcc4.2)

Dear forummers,
I have recently installed Lion on my macbook and then I installed the new Xcode, but upon discovering that the terminal gcc was no longer working I also installed that through Xcode(sth like command line tools).

Anyway, gcc is installed, but it works very strangely. The function rand() began no longer working properly(always giving me approx. same numbers), and even a simple for loop stopped working, getting stuck in the last term of it and not being able to escape from it.

I might post code here, but it won't be of use: My program was working perfectly till I got the new gcc. I can't believe I am the only one having difficulties with the new gcc.

Upon entering "gcc -v" it returns: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
ClausW is offline   0 Reply With Quote
Old Mar 24, 2012, 09:44 AM   #2
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by ClausW View Post
Dear forummers,
I have recently installed Lion on my macbook and then I installed the new Xcode, but upon discovering that the terminal gcc was no longer working I also installed that through Xcode(sth like command line tools).

Anyway, gcc is installed, but it works very strangely. The function rand() began no longer working properly(always giving me approx. same numbers), and even a simple for loop stopped working, getting stuck in the last term of it and not being able to escape from it.

I might post code here, but it won't be of use: My program was working perfectly till I got the new gcc. I can't believe I am the only one having difficulties with the new gcc.

Upon entering "gcc -v" it returns: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
Two possibilities: 1. Your program contained some serious bugs, but worked by pure chance with the older compiler version. 2. Your program was correct, but the newer compiler version is broken. So what is more likely? Without code, we won't know. If an experienced developer thinks they ran into a compiler bug, there is a 99% chance they are wrong. For inexperienced developers the number is higher.

I'd try a different compiler, like LLVM, and see what happens. If you have XCode 4.3.1, you could try LLVM and the new standard library implementation.
gnasher729 is online now   0 Reply With Quote
Old Mar 24, 2012, 10:39 AM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by ClausW View Post
The function rand() began no longer working properly(always giving me approx. same numbers), ...
rand() must be seeded. If you don't seed it, or seed it with the same or similar values, it will produce the same or similar outputs.

This is one reason the man page's brief description for rand is this:
rand, srand, sranddev, rand_r -- bad random number generator
(Emphasis added)

Frankly, without knowing how you're seeding it, and without knowing how you're using it, there's no way to diagnose the problem. The same thing goes for your "simple for loop". We don't know what you coded, and anyon'e idea of a simple for loop can mean anything in the actual code.

In short, without code, it's all just guessing.
chown33 is online now   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Sleep no longer working properly simps100 OS X Mavericks (10.9) 0 Apr 19, 2014 08:28 PM
Table of Contents finally works properly in the new Pages! JD92 Mac Applications and Mac App Store 1 Oct 24, 2013 11:51 AM
TV shows downloaded from iTunes no longer play properly SpectreOne3 Mac Applications and Mac App Store 0 Apr 6, 2013 10:02 PM
iPhone: Notifier+ No Longer Works bertie343 Jailbreaks and iOS Hacks 0 Feb 6, 2013 07:04 PM
Networking no longer working properly after 10.8.2, help Boomish69 OS X 0 Sep 25, 2012 03:45 PM

Forum Jump

All times are GMT -5. The time now is 01:20 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC