Help with Text Wrangler

Joined
Sep 25, 2011
Messages
52
Reaction score
0
Points
6
Location
San Antonio, TX
Your Mac's 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?
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
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
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You really only need the shebang line for interpreted languages. It works to tell your shell how to execute a script if it has executable privileges. For example, let's say you have a Python script and you make it executable (so you don't have to invoke the Python interpreter). The shebang at the beginning tells the shell that this is a Python script that needs to be interpreted by Python.

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.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
If you want to run your code, from within your development software, you're gonna need an IDE.. well, you already have xCode :)
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
If you want to run your code, from within your development software, you're gonna need an IDE.. well, you already have xCode :)
Pfft, Vim can handle it just fine:
Code:
:!gcc %
:!./a.out
Or, better yet:
Code:
:!gcc % -o name_of_app
:!./name_of_app
Who needs an IDE? :p
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
hey, I may be a cli guy... but I still don't feel right pushing people into vi :D
 
OP
Hexen
Joined
Sep 25, 2011
Messages
52
Reaction score
0
Points
6
Location
San Antonio, TX
Your Mac's 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.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
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.
There's no way around this - C++ is a compiled language. You can not interpret C++ code for it wasn't designed that way and never has been.

If you hate C++, might I ask why you're using it?
 
OP
Hexen
Joined
Sep 25, 2011
Messages
52
Reaction score
0
Points
6
Location
San Antonio, TX
Your Mac's 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.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
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?
 
OP
Hexen
Joined
Sep 25, 2011
Messages
52
Reaction score
0
Points
6
Location
San Antonio, TX
Your Mac's 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.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
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. ;)
 
OP
Hexen
Joined
Sep 25, 2011
Messages
52
Reaction score
0
Points
6
Location
San Antonio, TX
Your Mac's 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.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
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.
 
OP
Hexen
Joined
Sep 25, 2011
Messages
52
Reaction score
0
Points
6
Location
San Antonio, TX
Your Mac's Specs
MacBook Pro 13"(Early 2011) 2.3 Ghz Intel Core i5 Mac OS X 10.8.2
It does seem very unforgiving. The errors that pop up are also too cryptic. Thanks for all the help!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top