Obj C build errors in SnowLeopard

Joined
Jul 21, 2010
Messages
1
Reaction score
0
Points
1
Hi,

I am pretty new to XCode and Web Objects/ Objective C apps.

I am trying to build an existing Obj C app on my local machine that runs OS X 10.6.2 and getting the below error:

My XCode version is 3.2 and the cc used is gcc-4.0

regexp_stuff.m:1501:23: error: macro "strncpy" requires 3 arguments, but only 1 given
regexp_stuff.m: In function ‘_MOregsub’:
regexp_stuff.m:1501: error: ‘strncpy’ redeclared as different kind of symbol
regexp_stuff.m:1501: warning: unused variable ‘strncpy’


Please let me know if you have any pointers on how to debug this issue.

Thanks!
 
Joined
Feb 25, 2009
Messages
2,112
Reaction score
71
Points
48
Your Mac's Specs
Late 2013 rMBP, i7, 750m gpu, OSX versions 10.9.3, 10.10
It would really help to see your code - just seeing the error only gives part of the picture.

For example:

" regexp_stuff.m:1501:23: error: macro "strncpy" requires 3 arguments, but only 1 given "

would be given probably because there is a functioned defined as strncpy that is part of the strings library (in strings.h) and the prototype looks like:

char *strncpy(char *s1, const char *s2, size_t n);

so the compiler is wondering how come with a function that requires three parameters, you've only supplied 1.

in this:

regexp_stuff.m: In function ‘_MOregsub’:
regexp_stuff.m:1501: error: ‘strncpy’ redeclared as different kind of symbol
regexp_stuff.m:1501: warning: unused variable ‘strncpy’

In a function you have created, it appears you have defined strncpy as something else, which is giving the compiler a headache because it's already aware of a function called strncpy, you don't want local variables to have the same name as functions otherwise you run into ugly errors.

The last one is potentially nothing important - it's just stating you declared a variable but didn't actually use it in the function.

It's kind of like doing:

int addInts(int a, int b)
{
int x;

return a+b;
}

I declared x but didn't actually use it in the function - the compiler is letting you know that you have a variable in there that is either wasted space or you managed to forget to include it in what you were doing.
 

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