Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

the87boy

macrumors newbie
Original poster
Sep 11, 2007
3
0
On my university we are starting to have C-programmering, but I can't set up X-code on my MAC, so I can start programmering. The reason why I can't set up X-code is, that I don't know which project-type, I should choose, because there are no project just about C
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
You need to select something like Command line foundation tool (sorry don't have XCode installed on this Mac right now to give the exact name...)
 

mashkina

macrumors member
Nov 4, 2006
48
0
Dubai
On my university we are starting to have C-programmering, but I can't set up X-code on my MAC, so I can start programmering. The reason why I can't set up X-code is, that I don't know which project-type, I should choose, because there are no project just about C

The XCode comes in the installation disk(s) of your Mac. You don't need to install MacOS again. There is a file there with the name "Xcode installation". I don't know if that is your problem. On the other hand ANSI-C is compatible with the Mac C. The differences are just in some definitions, such as "float32" instead of "float", for instance. If U want to program in Object C (C++) I cannot help you much with that.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
On my university we are starting to have C-programmering, but I can't set up X-code on my MAC, so I can start programmering. The reason why I can't set up X-code is, that I don't know which project-type, I should choose, because there are no project just about C

For plain C programs, use "Standard Tool". For plain C++ programs, use "C++ Tool".
 

garethlewis2

macrumors 6502
Dec 6, 2006
277
1
First things first.

You should not be using XCode to learn C programming with. It is like using a sledge hammer to crack a wallnut. Complete overkill.

Secondly XCode will hide too many details. Unless you use the gcc tools from the command line, you will never understand the difference between compiling and linking code. You will think everything works when you press the hammer tool.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
First things first.

You should not be using XCode to learn C programming with. It is like using a sledge hammer to crack a wallnut. Complete overkill.

Secondly XCode will hide too many details. Unless you use the gcc tools from the command line, you will never understand the difference between compiling and linking code. You will think everything works when you press the hammer tool.

Why overkill? If he's learning C, he should be concentrating on learning C, and everything else is just obstacles. No point in learning to use the linker if that means falling behind in your C course and having trouble catching up. Using XCode is not like using a sledge hammer to crack a walnut, which is a very bad method because it doesn't leave you with anything edible - it is like using a sophisticated automated walnut cracker to crack walnuts.

I'd much rather that someone learns using XCode properly, how to use different build targets, how to generated x86 vs. PowerPC or 32 bit vs. 64 bit code, how to build a bundled application, add icons, add help files, plist files and so on than learning how to use a linker.
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
Using Xcode is not overkill. Actually, it is really efficient for beginners, as an IDE automates all unnecessary (for a beginner) steps and lets the beginner concentrate on the development process and not on the compilation process. After he/she has learnt the IDE, he/she may use the command line tool. Otherwise, it's not recommended.
 

garethlewis2

macrumors 6502
Dec 6, 2006
277
1
Oh dear.

Oh dear, oh dear.

C is a low level language. How are you going to work on an embedded environment if you don't know how to use the compiler or linker.

No don't answer that, based on your previous answers I would fall off my seat laughing.

Yes XCode is like cracking a wallnut with a sledgehammer. It doesn't take any command line switches to compile simple C programs. What happens if this guy gets a job with a software company that develops software in C that runs on a server with a textbased Ptty interface?

I will say it again. Oh dear. I just hope I never have to interview the two of you. I would probably have to leave the interview room to stop myself laughing.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Actually for some people I think X-code is a good place to start . Not everyone wants or needs to know about compiler and linker switches/options right from the word go. Choosing X-code as your first exposure to programming doesn't preclude learning the command line way in the future.
Anyway, the project preferences in X-code present an easy interface to playing around and reading up on the various switches. I honestly think this 'you have to learn from the bottom up' attitude is a bit over rated though. I mean where does it end? Surely you should be learning assembler before learning C? Or how about construct your own Turing machine out of ping-pong balls, buckets and springs :) Just my opinion… so don't jump on me!!!

b e n
 

garethlewis2

macrumors 6502
Dec 6, 2006
277
1
I won't jump on anyone, but I can pretty much guarantee that most of the assignments for a first class in C will be command based using a few files at most. They should be teaching this on Unix boxes or Linux boxes. Not because this is an elite way of doing it, but rather it is the home of C.

Also from a simple point of view, you have to unless the OP has a really rubbish university, hand in all source code and it has to be written to be easily compilable. Writing your programs in XCode and then trying to work out how to write a Makefile is going to end in a failure.

I still remember laughing when I read in Joel On Software that most universities in the US don't teach C anymore. It is too difficult so they teach Java, and then not even standard Sun Java, they give them wrapper classes that box and unbox integers automatically, so the students have no idea what the difference between and int and Integer is.
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
I won't jump on anyone, but I can pretty much guarantee that most of the assignments for a first class in C will be command based using a few files at most. They should be teaching this on Unix boxes or Linux boxes. Not because this is an elite way of doing it, but rather it is the home of C.

Also from a simple point of view, you have to unless the OP has a really rubbish university, hand in all source code and it has to be written to be easily compilable. Writing your programs in XCode and then trying to work out how to write a Makefile is going to end in a failure.

I still remember laughing when I read in Joel On Software that most universities in the US don't teach C anymore. It is too difficult so they teach Java, and then not even standard Sun Java, they give them wrapper classes that box and unbox integers automatically, so the students have no idea what the difference between and int and Integer is.

I think you make some very good points, Still, I think that there is no single right way or path to learn programming. Learning compiler flags and makefiles before learning how to do a for loop is one way to start, but perhaps not suited to everbody, and I'm not entirely convinced that there is any long lasting intrinisic benefit from doing it that way anyway. In the end does it really matter what came first, the makefile or the IDE?

b e n
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
At my university, the first C class was originally taught on Windows XP using PuTTY to access Linux machines, in turn using gcc and vi. I don't remember people having too much trouble with that setup, I just remember them having problems with the syntax of C. But now, a few years after I originally took the course, they have switched it all over to VS, which is a pity since I do believe you should be familiar with the command line before moving to an IDE.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
C is a low level language. How are you going to work on an embedded environment if you don't know how to use the compiler or linker.

No don't answer that, based on your previous answers I would fall off my seat laughing.

Feel free to fall off your seat.

The guy is doing a C course. He isn't doing a course in writing software for embedded environments. When you learn driving, you don't start by learning to change the oil in your car. You get into the car and learn holding on to the steering wheel and moving the car in a straight line, stopping when necessary. A bit later you learn how to drive a curve. Way, way later you may learn how to change the oil, but some people never bother learning it and can still drive very well. Learning how to get someone else to change the oil for you is a very good technique, works for most drivers.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
I will say it again. Oh dear. I just hope I never have to interview the two of you. I would probably have to leave the interview room to stop myself laughing.

So do you have any idea how to integrate a few perl scripts into the XCode build process? Any idea what belongs into a plist file? How to process a reply to an AppleEvent? How to write 64 bit clean C code?

Should I ever have to start a C compiler on an embedded system, I'll just take the manual. Should I ever have to compile stuff on a server using ptty, I'll switch to archaeology and start digging for dinosaur bones. Learning to know everything is a very inefficient use of my time. Knowing who to ask, and knowing how to make them do it, is ten times more efficient.
 

MacDonaldsd

macrumors 65816
Sep 8, 2005
1,005
0
London , UK
I would do it in terminal to be honest with you. My first year we done everything on Windows in Visual studio, and now we just use linux.

I found it pain setting up the reading and writing to files as it was in a different manner using Visual Studio. You want to pass your course first and foremost.
 

the87boy

macrumors newbie
Original poster
Sep 11, 2007
3
0
What will you then recommend just to highlight C-code (syntax highlighting)?
It's the only thing, I'm missing except from gcc, but isn't it already installed?
 

philippott

macrumors newbie
Sep 17, 2007
18
0
What will you then recommend just to highlight C-code (syntax highlighting)?
It's the only thing, I'm missing except from gcc, but isn't it already installed?

Regarding your C classes I think you wont need any sophisticated library or frameworks at the beginning.

The easyiest way is still:

1) install xcode (with defaults). Xcode is available for download from Apple and it usually also ships on their install DVD - the late 2006 imac I have here has it on the DVD - cant remember if #1 or #2 though.

2) make a folder in your home directory, use Terminal.app to go there

3) launch XCode, click New Empty File

4) enter something like

#include <stdio.h>

int main(int argc, char *argv[])
{
printf("Hello World\n");
return 0;
}

5) save it as test0001.c into this new folder - and voila, syntax highlighting will be turned on

6) in the Terminal window you can compile test0001.c with

gcc -Wall test0001.c -o test0001

and run it with

./test0001

You dont need to buy or download any other software (syntax highlighting supporting text editor etc) and this way you can stick closely to a basic C class.

Regards
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Learning to use the command line to compile and link isn't a big deal, and once you know how to do it I can't really see any point for not moving over to X-code. An advantage of using X-code is that you will be able to debug your program using X-codes front end to the debugger. Stepping through your code is a good way to understand how your program works, and why it doesn't work, and X-code's debugger makes this a breeze.

b e n
 

jimbohampton

macrumors newbie
Sep 14, 2007
1
0
another problem besides xcode

Did anyone else notice that he uses the spelling "programmering"... TWICE. I think he has more basic problems than figuring out how to use xcode.
 

mward333

macrumors 6502a
Jan 24, 2004
574
33
Wow, give this guy a break. Two or three of the posts above are so abrasive! We should be a friendly, inviting community.

To the OP-- Good luck starting to learn the C language. It is a fun and challenging process. Everybody on this forum went through the process, and you are invited to the party! I write C++ nearly every day for my research, and I really enjoy this practical side of my job. (I'm a university professor.)

So stick with it, and let us know when you have trouble. We're here to help.

Please forgive the folks who are not-too-understanding. Don't worry about it.
 

fimac

macrumors member
Jan 18, 2006
95
1
Finland
...
4) enter something like

#include <stdio.h>

int main(int argc, char *argv[])
{
printf("Hello World\n");
return 0;
}

5) save it as test0001.c into this new folder - and voila, syntax highlighting will be turned on

6) in the Terminal window you can compile test0001.c with

gcc -Wall test0001.c -o test0001

and run it with

./test0001
...

This is good advice.

This thread reminds me of the beginning of K&R where IIRC the authors say that the hardest step is simply to get something to compile, link and run. After that everything gets easier ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.