Results 1 to 2 of 2
  1. #1


    Member Since
    Jul 21, 2010
    Posts
    1
    Obj C build errors in SnowLeopard
    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!

  2. #2


    Member Since
    Feb 25, 2009
    Posts
    2,112
    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.
    My Macs: Late 2013 rMBP w/ 750m, 16Gig ram; 2013 Mac Pro 6 core w/ D700, 16Gig Ram; Mac mini G4, 1.25 GHz, 512m ram (server); Late 2011 11" MBA, 1.8GHz i7, 4Gig Ram, 256Gig SSD, HD3000; Powerbook 12" G4 1.33GHz running Linux; Apple TV (1080p version)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Location monitoring based on IP Using Obj C
    By faisaliqbal in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 05-20-2014, 12:03 PM
  2. Xcode 4: Add Build Carbon Resources Build Phase
    By Tommato in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 06-15-2012, 02:27 PM
  3. Very fundamental question in Obj-C
    By zijianz in forum iOS Development
    Replies: 3
    Last Post: 05-23-2012, 03:39 PM
  4. Help with Obj C - creating multiple objects
    By capturenow in forum iOS and Apps
    Replies: 3
    Last Post: 09-23-2011, 01:55 PM
  5. Compare part of a string in Obj C
    By thibaujd in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 02-10-2011, 08:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •