Project Builder on Mac OS X

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Project Builder on Mac OS X
Off With Their Heads
Member # 4045
Profile Homepage #0
So I was thinking that it would be fun over this winter break to learn how to program in C. Nothing fancy, just some basic stuff. When I double-click on C source code (like, say, the BoA Editor source, which is why this is SW-related, if tangentially, since my intention eventually is to much with the BoA Editor) an application called Project Builder opens up. I think it's a development application, like the Codewarrior Gold program that Jeff uses, except this one's free with my computer.

Now, here's my question: I'm looking at a book that is an intro to C, and it gives samples of code to start out with. Nothing fancy, again, just
main()
{
printf("Hello, world!");
}
I want to write this code and then compile it and run it. How do I get Project Builder to do this?

And in response to the most obvious answer, when I try to make a new file, type this in, and compile it, it creates a whole host of other files and gives me a variety of errors and misbehaves quite badly.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Post Navel Trauma ^_^
Member # 67
Profile Homepage #1
Project builder is probably overkill for that sort of thing, although you can do it. You want the project type "Tool" or somesuch.

If I were you, I'd use Project Builder only to edit the files, not part of any project. Then go to terminal and compile them with "cc thingname.c -o thingname" or perhaps "make thingname"

--------------------
Barcoorah: I even did it to a big dorset ram.

desperance.net - Don't follow this link
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Off With Their Heads
Member # 4045
Profile Homepage #2
Uh... new thought. Can I just write the code in a text editor and compile it using Terminal?

Ick. I guess now I have to learn what Terminal is and how it works.

EDIT: This seems to work. Kind of. Although it would be nice to have some kind of debugger.

[ Thursday, December 23, 2004 13:38: Message edited by: Kelandon ]

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 5091
Profile #3
Does OS X include gdb or some frontend thereof?

Is the CC for OS X gcc?

By the way, that code snippet isn't proper ANSI C. It's proper K&R C, but you should probably learn the proper way to do it.

Are you not getting any output from it? That's because you need a newline after the message.

#include <stdio.h>

int main()
{
printf("Hello, world!\n");
return 0;
}
Then compile it thusly, assuming it's saved as hello.c ($ is your prompt):

$ cc hello.c -o helloAnd then run it, and if all goes well, a message!

$ ./hello
Hello, world!

Posts: 180 | Registered: Friday, October 15 2004 07:00
Master
Member # 4614
Profile Homepage #4
Yeah, I think your biggest problem was forgetting the first line in Djur's code:
#include <stdio.h> It's a required header file for the printf function to work, if I'm correct.

--------------------
-ben4808

For those who love to spam:
CSM Forums
RIFQ
Posts: 3360 | Registered: Friday, June 25 2004 07:00
Off With Their Heads
Member # 4045
Profile Homepage #5
Evidently my book is just too old. My dad claimed that it would still be more or less the same, but I looked at the copyright, and the thing is from 1990.

Oh well. I'll just get a new book, I guess.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 5091
Profile #6
quote:
Originally written by Kelandon:

Evidently my book is just too old. My dad claimed that it would still be more or less the same, but I looked at the copyright, and the thing is from 1990.

Oh well. I'll just get a new book, I guess.

C was standardized in 1989, so that book should be fine in terms of date. Maybe it just sucks.

Truth be told, C89 does keep the implicit int rule, but you should still never assume the return value of any function, period.

If it left out the #include, however, the book is probably worthless.

ben: Not necessarily. C89 allows implicit declaration. If you leave out the stdio.h header, the compiler will automatically prototype printf as int printf(char*), which will work.

By the way, int main(void) is generally better than int main(), now that I think about it. Traditionally, func() has been interpreted as func(...), which is not what you want at all. Of course, ISO C doesn't allow variadic functions without a named first argument, but it's still something to think about.

[mboeh@debs]~% cat > hello.c
int main()
{
puts("Hello, world!");
return 0;
}
[mboeh@debs]~% gcc hello.c -o hello
[mboeh@debs]~% ./hello
Hello, world!


[ Thursday, December 23, 2004 16:10: Message edited by: The Dog And Pony Show ]
Posts: 180 | Registered: Friday, October 15 2004 07:00
Off With Their Heads
Member # 4045
Profile Homepage #7
Having searched further, I discovered that the book had a complicated installation process to set up the environment that essentially had the same effect as the "include" thing.

Does anyone know of a program other than Project Builder that I can get cheap or for free for a Mac that will be easier than using a text editor? Right now I'm working on my family's Windows NT machine, but I want to be able to do this on my own computer someday.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Shock Trooper
Member # 4557
Profile #8
XCode is a free Mac OS X compiler that uses the GCC collection. Don't know much about it since I use Windows, but if it uses GCC it should be pretty good.

If you end up using windows, I'd suggest using Dev-C++ (free) or if you get enough money, something from Borland.

If none of these appeal to you, you could always learn how to create makefiles and compile programs using make (an extension to GCC):
Makefile Tutorial

(I found a much better tutorial before, but can't
seem to find it again.)
Posts: 264 | Registered: Wednesday, June 16 2004 07:00
Off With Their Heads
Member # 4045
Profile Homepage #9
XCode also requires OS 10.3. I have 10.2.

--------------------
Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens.

Kelandon's Pink and Pretty Page!!: the authorized location for all things by me
The Archive of all released BoE scenarios ever
Posts: 7968 | Registered: Saturday, February 28 2004 08:00
Warrior
Member # 3351
Profile #10
There is SimpleText in the developper tools for the simpler projects.
SubEthaEdit seems good but I haven't used it a lot.

Also, you can launch emacs or vi (vim) from the terminal.

--------------------
/Seawinds are calling
Posts: 187 | Registered: Thursday, August 14 2003 07:00
Post Navel Trauma ^_^
Member # 67
Profile Homepage #11
OS X does include gdb. To use it, type "gdb myprogram". It'll work better if you compile your program with debugging information in it, thusly: "cc myprogram.c -g -o myprogram"

The CC for OS X is GCC, but I don't know whether it can be invoked on 10.2 by typing gcc.

It should still give output, if it doesn't have the newline at the end. It's just that the shell prompt will be appended to it in a rather ugly manner.

As for a free good programming text editor, I just get by with the one that comes with project builder.

--------------------
Barcoorah: I even did it to a big dorset ram.

desperance.net - Don't follow this link
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Warrior
Member # 5091
Profile #12
It actually depends on your terminal and shell whether strings without a newline will be shown.

[mboeh@debs]~% gcc hello.c -o hellp0
[mboeh@debs]~% ./hellp0
[mboeh@debs]~% ./hellp0; echo
Hello, world!
XTerm(196), Xorg 6.8.1, zsh 4.2.0.

mboeh$ ./hellp0
Hello, world!mboeh$
Same, with bash 2.05.

Doesn't OSX 10.2 use tcsh, though, as befits a BSD variant?

> ./hellp0
Hello, world!>
tcsh 6.13.00.

Thus, one's mileage may certainly vary.

EDIT: Does OS X come with a gdb frontend like ddd? gdb can be pretty incomprehensible to people new to it. I'm still kind of clumsy with it, and I've been using it for almost 7 years.

[ Friday, December 24, 2004 11:55: Message edited by: The Dog And Pony Show ]
Posts: 180 | Registered: Friday, October 15 2004 07:00
Shock Trooper
Member # 4557
Profile #13
quote:
Originally written by Kelandon:


Does anyone know of a program other than Project Builder that I can get cheap or for free for a Mac that will be easier than using a text editor?

Try looking at these:

Bakefile
QMWEdit
WideStudio
Posts: 264 | Registered: Wednesday, June 16 2004 07:00
Agent
Member # 2210
Profile #14
Sourceforge is an interesting site. It has a lot of free software which is pretty high powered. I am not a programmer, but here is the link to Dev- C++

Dev C++

--------------------
Wasting your time and mine looking for a good laugh.

Star Bright, Star Light, Oh I Wish I May, I Wish Might, Wish For One Star Tonight.
Posts: 1084 | Registered: Thursday, November 7 2002 08:00
Post Navel Trauma ^_^
Member # 67
Profile Homepage #15
It seems that with Terminal.app, bash and tsch both show things without a newline:
(4)[~/insane] khoth: ./h
Hello(5)[~/insane] khoth: bash
Fenrir:~/insane khoth$ ./h
HelloFenrir:~/insane khoth$
Some versions of OS X use tcsh by default, others use bash. I don't know which ones use what.

--------------------
Barcoorah: I even did it to a big dorset ram.

desperance.net - Don't follow this link
Posts: 1798 | Registered: Thursday, October 4 2001 07:00
Shock Trooper
Member # 4557
Profile #16
quote:
Originally written by Eggs with Toast:

I am not a programmer, but here is the link to Dev- C++

Dev C++

Dev-C++ is for windows only. For OS X I couldn't find anything as powerfull ( for free ).

[ Tuesday, December 28, 2004 13:30: Message edited by: KernelKnowledge12 ]
Posts: 264 | Registered: Wednesday, June 16 2004 07:00
Warrior
Member # 3698
Profile Homepage #17
i m pretty sure that terminal is unix

IMAGE(http://www0.info.apple.com/images/discussions/Images/bapple/glyphs/terminal.gif)
That terminal right?

--------------------
Hi. Why is the universe so BIG? Why am I human? How come hot dogs come in packages of 10 and buns 8? This will all be solved in time young padawan. Your quest for the ultimate Aztec manuer is coming to a climax. May the force be with you!!!
······························································
This is where I want you to click! Rate me! Ha Ha
Check out my GF 1, 2 and 3 Helper!
Ceck out some cool Mac OS X Apps that were made by me here!
10101 Software - You can take my iMac when you pry my cold, dead fingers off the wireless mouse!
Posts: 179 | Registered: Tuesday, November 18 2003 08:00