| OS X - Apps and Games Discussion of applications and games available for Mac OS X. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Sep 25, 2011
Location: San Antonio, TX
Posts: 52
![]() Mac Specs: MacBook Pro 13"(Early 2011) 2.3 Ghz Intel Core i5 Mac OS X 10.8.2
|
I've been using Text Wrangler for a day and I've programmed in Perl, Python, and Shell Script already, but when I try to program in C++, I'm stuck in a rut. If I include the shebang line #!/usr/bin/gcc I get a C++ error that says "invalid preprocessing directive." If I remove the shebang line, I get a Text Wrangler error. Anybody know how to get rid of these errors?
|
| QUOTE Thanks | |
![]() Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,511
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff
|
Ohhhhhhhh remove the shebang, save the file in textwrangler then compile it. Yea, #!/usr/bin/gcc won't work.. and I don't think textwrangler will actually run the compiler
mike This machine kills fascists Got # ? phear the command line! |
| QUOTE Thanks | |
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,283
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
Since C/C++/Obj-C compile to native code, the shebang is useless since no interpreter needs to be invoked. In those languages, the hash mark actually signifies something else (preprocessor directives). Valid examples include #define and #include and invalid examples include your shebang line. As dys said, remove it and try again. Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
||||
| QUOTE Thanks | |||||
![]() Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,511
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff
|
If you want to run your code, from within your development software, you're gonna need an IDE.. well, you already have xCode
mike This machine kills fascists Got # ? phear the command line! |
| QUOTE Thanks | |
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,283
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
Quote:
Code:
:!gcc % :!./a.out Code:
:!gcc % -o name_of_app :!./name_of_app
Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
|
| QUOTE Thanks | ||
![]() Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,511
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff
|
mike This machine kills fascists Got # ? phear the command line! |
| QUOTE Thanks | |
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,283
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
| QUOTE Thanks | |
![]() Member Since: Sep 25, 2011
Location: San Antonio, TX
Posts: 52
![]() Mac Specs: MacBook Pro 13"(Early 2011) 2.3 Ghz Intel Core i5 Mac OS X 10.8.2
|
That's what I had to do. I had to compile it through Terminal using g++ -o, and then running the executable. I hate C++, I've been trying to configure Eclipse to run it. When I first tried I couldn't build the binaries, then after that I get an error message about the architecture that I read was caused by OS X being 64-bit. So I tried Text Wrangler, and I had problems too! But I have it now, I guess. I just have to turn all my files into executable files, but I made it easier on myself by creating aliases to do it easier and quicker. I know everyone says to use Xcode, but truth be told, I don't really like Xcode. It's too bloated for me
Thanks for all the replies.
|
| QUOTE Thanks | |
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,283
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
Quote:
If you hate C++, might I ask why you're using it? Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
|
| QUOTE Thanks | ||
![]() Member Since: Sep 25, 2011
Location: San Antonio, TX
Posts: 52
![]() Mac Specs: MacBook Pro 13"(Early 2011) 2.3 Ghz Intel Core i5 Mac OS X 10.8.2
|
Because I read that it's the lingua franca of programming languages and I've seen it for myself. Like I said before, I learned Java last semester and I can understand bits and pieces of other languages because of Java's similarities to C/C++, and I like that. Not only that, but from what I've read, C++ has a wider possibility of applications than Java. Yeah I know, all of this is based on other people's testimonials, but I take their word for it. Besides, it can't hurt to know another language, right? I guess I don't hate C++, because I really haven't been able to program in it.
|
| QUOTE Thanks | |
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,283
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
I suppose it's the lingua franca for certain requirements but this all depends on what you want to accomplish. If you want to do lower level programming, C is the way to go. For other projects, C is a terrible choice (relationally). What kinds of things do you want to develop?
Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
| QUOTE Thanks | |
![]() Member Since: Sep 25, 2011
Location: San Antonio, TX
Posts: 52
![]() Mac Specs: MacBook Pro 13"(Early 2011) 2.3 Ghz Intel Core i5 Mac OS X 10.8.2
|
I have no idea yet, I have a year and a half to figure it out though
Probably programs on a professional level, but I also have an interest in programming hardware (musical applications like the Noise Toy), in which case I assume C would be good since it's lower level. Honestly, I'm just trying to learn as much as possible right now.
|
| QUOTE Thanks | |
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,283
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
Oh, please don't let my questions and comments deter you from learning as much as possible. That's very much not the case. Learn as much as you can now while you have the freedom to do so.
![]() If you're going to be doing hardware level programming, the "C languages" are definitely worth some attention (and Assembly depending how "far down" you want to go). You may not like it for some higher level stuff but it can definitely be used since most major programs involve a "C language" somewhere. I can't speak to your preference though - that's all you. Admittedly, part of my questioning comes out of my dislike for C/C++/Obj-C and strong preference for Python and Javascript.
Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
| QUOTE Thanks | |
![]() Member Since: Sep 25, 2011
Location: San Antonio, TX
Posts: 52
![]() Mac Specs: MacBook Pro 13"(Early 2011) 2.3 Ghz Intel Core i5 Mac OS X 10.8.2
|
Ha! Hopefully the freedom doesn't ever go away...
I don't want to even think about Assembly, there is no way that I would ever want to go that far. I'll be happy learning C in some variation. But I've been playing around with C++ all day--it's my last day of vacation, and I'm programming!--and it does seem like it's not the best language for higher level tasks, but I'm sure it does have it's applications. I've been looking into Python too. I have Ubuntu installed as a Virtual Machine on my Mac, and I've looked at some of the files and it looks like a promising language. I've played around with it a bit on Terminal, but I'm looking for a good tutorial at the moment. What do you have against C? I've seen a lot of people on various forums that have nothing good to say about C. |
| QUOTE Thanks | |
![]() Member Since: Oct 19, 2008
Location: Ottawa
Posts: 15,283
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: 2012 13" MBP (2.5 i5, 8GB)
|
It's unforgiving and doesn't have a garbage collector. I also don't like the syntax but that's a fairly minor point in the grand scheme of things.
Important Links: Community Guidelines : Use the reputation system if you've been helped. M-F Blog :: Write for the blog :: M-F IRC Channel - Chats every Sunday at 8PM EST. |
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Why we appreciate grammar here at Mac Forums! | BlueMac | Community Suggestions and Feedback | 55 | 12-11-2012 01:12 PM |
| Working with text boxes in MS Office for Mac 2011 | eebelz | OS X - Apps and Games | 0 | 08-17-2011 06:47 PM |
| strange, erratic behavior... | nuno1959 | OS X - Operating System | 11 | 05-05-2010 08:56 PM |
| text reflow problems from Quark 4.1 to Quark 6.5 | plevault13 | Running Windows (or anything else) on your Mac | 2 | 09-30-2005 02:59 PM |
| text reflow problems from Quark 4.1 to Quark 6.5 | plevault13 | OS X - Apps and Games | 0 | 09-30-2005 01:57 PM |
All times are GMT -4. The time now is 02:57 AM.
Powered by vBulletin