docPath declaration question


#1

Hi,

in BNRAppDelegate.h we declare

NSString *docPath(void); // why do we use void here ? I assume, because no input parameter will be accepted, when called

in BNRAppDelegate.m we implement it

NSString *docPath() // why is there no “void” within the brackets ? Shouldn’t both notations be equal ?
{

}

Thanks

Klaus


#2

Yes and Yes


#3

So, if both should be equal, why aren’t they ?


#4

They are the same; only a matter of style. To convince yourself, just edit and compile.

Style 1:

NSString *docPath (void);
...
NSString *docPath (void);
{
...
}

Style 2:

NSString *docPath ();
...
NSString *docPath ();
{
...
}

SomeType Foo () is identical to SomeType Foo (void)

//  main.m

#import <Foundation/Foundation.h>

void Foo ();
void Foo (void);

int main (int argc, const char * argv[])
{
     Foo ();
}

#if 1         // <--- change 1 to 0 and compile and run again
void Foo ()
{
    NSLog (@"%s: %s %d", __PRETTY_FUNCTION__, __FILE__, __LINE__);
}
#else
void Foo (void)
{
    NSLog (@"%s: %s %d", __PRETTY_FUNCTION__, __FILE__, __LINE__);
}
#endif

#5

Thank you !