XCode or Terminal?

Moderator
Posts: 1,560
Joined: 2003.10
Post: #31
Hairball183 Wrote:The thing it keeps warning me about is that I have my main() property set to "void" instead on "int".
Easy fix.

Code:
#include <stdlib.h>

int main(int argc, const char ** argv) {
  // ...
  
  return EXIT_SUCCESS;
}
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #32
C requires that main return int, and allows it to take zero or two arguments. Pretty sure C++ requires that it take two arguments.
Quote this message in a reply
Member
Posts: 72
Joined: 2006.10
Post: #33
The warning balloons being disruptive is by far the greatest thing about said balloons. They placate inexperienced programmers' errors in their face and forces them, out of annoyance, to fix their code.

I can't say this enough: Warnings are NOT acceptable. -Werror should be enabled by default. The only exception to this rule is when compiling third party libraries made by people who tolerate warnings or, in their defense, sometimes use a different compiler. If you get warnings while building, fix them and fix them soon. If you brush them off thinking "I'll fix it later", then the warnings will just start piling up.

If your block of code is impossible to fix without a warning, disable it. In extreme cases, #pragmas can be used to locally disable a given warning. However, this is VERY rare. In a professional context, it generally takes a second, or even a third, opinion before letting a warning slide.

Anyways, warnings generally mean that you are doing something wrong.
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #34
sohta Wrote:The warning balloons being disruptive is by far the greatest thing about said balloons. They placate inexperienced programmers' errors in their face and forces them, out of annoyance, to fix their code.

I can't say this enough: Warnings are NOT acceptable. -Werror should be enabled by default. The only exception to this rule is when compiling third party libraries made by people who tolerate warnings or, in their defense, sometimes use a different compiler. If you get warnings while building, fix them and fix them soon. If you brush them off thinking "I'll fix it later", then the warnings will just start piling up.

If your block of code is impossible to fix without a warning, disable it. In extreme cases, #pragmas can be used to locally disable a given warning. However, this is VERY rare. In a professional context, it generally takes a second, or even a third, opinion before letting a warning slide.

Anyways, warnings generally mean that you are doing something wrong.

So how do you enable -Werror?
Quote this message in a reply
Member
Posts: 72
Joined: 2006.10
Post: #35
Hairball183 Wrote:So how do you enable -Werror?

IIRC, There is a compiler option called "Treat Warnings as errors" that enables it. Being at work right now, I can't check for sure... Otherwise, you can add -Werror to your "Other compiler flags"
Quote this message in a reply
Member
Posts: 63
Joined: 2005.12
Post: #36
OneSadCookie Wrote:C requires that main return int, and allows it to take zero or two arguments. Pretty sure C++ requires that it take two arguments.
main() can take zero arguments in C++ as well.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #37
Yup, turns out C++ is more flexible, not less.

http://www.open-std.org/jtc1/sc22/wg21/d...tml/oct97/ appears to be some version of the standard; difficult to acquire the "real" thing. Search for "basic.start.main" in section 3 (Basic concepts). This seems to say that the arguments accepted by main are implementation-dependent, but must include at least () and (int, char*[]).
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #38
There are some truly annoying warnings, however. Such ones include comparison of a signed vs. unsigned integer (for things such as comparing an unsigned int with a literal, enum, etc.) or loss of precision warnings. (such as if you're doing a binary operation on 2 shorts) I will often turn off warnings such as that, but otherwise I leave most of them on. GCC seems to be a little lighter on the annoying warnings than the Microsoft compiler, from what I can tell.
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #39
ya, I've noticed that the Microsoft compiler complains about things a lot more than gcc. It's nice sometimes, but sometimes it generates so many that the temptation is to just turn the warnings off completely. Microsoft's warnings about 'unsafe functions' such as strcpy vs strcpy_s are particularly annoying until you turn them off.

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Member
Posts: 72
Joined: 2006.10
Post: #40
wyrmmage Wrote:ya, I've noticed that the Microsoft compiler complains about things a lot more than gcc. It's nice sometimes, but sometimes it generates so many that the temptation is to just turn the warnings off completely. Microsoft's warnings about 'unsafe functions' such as strcpy vs strcpy_s are particularly annoying until you turn them off.

I don't think it's really that cut and dry. Just the other day, I had hell porting someone's Microsoft Visual C++ code to GCC because Microsoft's compiler lets you use templated subtypes directly, while GCC requires you to explicitly use typename when using them in the template class to declare parameters or local variables. So many files to change... so many... Mind you, you could blame this on the Microsoft compiler being too lenient. I guess my point is that they are different. One being more annoying than the other is not cut and dry by any stretch of the imagination.

BTW, while this is not the forum for this, I'm pretty sure that the deprecated unsafe function warnings are defined in the Microsoft stdc headers You are supposed to use a few defines (2 or 3 depending on which functions you use) in order to disable those. It has nothing to do with the compiler.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #41
Using typename for templated subtypes is part of the language specification, so you can blame Microsoft for not conforming to the specification.

You don't really have to disable all warnings to get rid of the annoying ones. You can disable warnings based on the warning number. If I find an annoying one, I'll look it up and disable it if it's especially common. It's useful since I do all of my dev work on OS X, then boot up on Windows to make sure it compiles/works. (I still prefer to have warning free code on both platforms, though)

And yes, unsafe function (and deprecation of half the standard library) warnings can be disabled through preprocessor defines. I don't know them off the top of my head, though...
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #42
ya, I know how to get rid of the unsafe function warnings through defines, just saying that it gets annoying sometimes Wink

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  SVN: Terminal or XCode... Nevada 8 5,375 Aug 5, 2007 01:35 AM
Last Post: BeyondCloister
  Compiling in the Terminal Nick 5 3,138 Sep 8, 2005 04:28 PM
Last Post: Nick
  /sw/lib/libcurl.2.dylib to /usr/lib/??? (terminal...???) BinarySpike 10 6,359 May 2, 2005 10:05 AM
Last Post: BinarySpike