tags:

views:

49

answers:

2

I am using C++ compiler GCC 4.2 in XCode 3.2.2. I have noted that the compiler will successfully compile a method foo even though there are no ellipses. The header and method are properly declared as foo(), but when I do a find and replace either by file or by program-wide it will miss approximately 2-3% of the changes [foo to foo(). This would not be critical if the compiler did not give an erroneous successful build. I have not found that this to occur with: foo(any parameter). Does anyone have any solution? Thank you.

+2  A: 

It's unclear from your question what you are actually asking about, but if it is function calls then:

void foo() {
}

int main() {
    foo();    // valid C++ - call foo
    foo;      // valid C++ - get  a function pointer
}

If you want a warning about the second use of foo, compile with the GCC -Wall flag (which you should really be using all the time in any case) - this will give you:

f.cpp:6: warning: statement is a reference, not call, to function 'foo'
f.cpp:6: warning: statement has no effect
anon
A: 

To add a GCC flag through xcode:

  1. Go to the "Project" menu and select "Edit Project Settings"
  2. Select the "Build" tab
  3. Find the "Other C++ Flags" setting and double click on the blank space to the right
  4. Click the plus sign and add "-Wall"
AdamG