Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7677107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:20:54+00:00 2026-05-31T17:20:54+00:00

I am getting duplicate error in my xcode while build and run I have

  • 0

I am getting duplicate error in my xcode while build and run

I have two files file1.m and file2.m both use same variable and function names

file1.h

#import <UIKit/UIKit.h>


@interface file1 : UIViewController {

IBOutlet UILabel *result;   

}

-(IBAction)home;

@end

file1.m

#include<file1.h>
@implementation file1
int count = 0;
int arr[2][2];

file2.h

#import <UIKit/UIKit.h>


@interface file2 : UIViewController {

IBOutlet UILabel *result;   

}

-(IBAction)home;

@end

file2.m

#include<file2.h>
@implementation file2
int count = 0;
int arr[2][2];

When Build and run it gives me error duplicate symbol “count” in file1.o and file2. o
if I change their names to count1 and count2 I will not get any error.

In both file1.m and file2.m I am trying to make global variables.

Is there any way by which I can use same names of variable and functions in both the files

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:20:56+00:00Added an answer on May 31, 2026 at 5:20 pm

    Make them static:

    static int count = 0;
    static int arr[2][2];
    

    Note that they’ll refer to different variables. If you want to them to refer to the same variables, leave it the way you have it in one file and declare them extern in the other file:

    extern int count;
    extern int arr[2][2];
    

    It’s common to put those extern declarations in a common header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the error I am getting: ld: duplicate symbol _main in /Users/wostler/Library/Developer/Xcode/DerivedData/UIPageViewControllerDemo-hjsgatcuhsxeokdnubifybpivzum/Build/Intermediates/UIPageViewControllerDemo.build/Debug-iphonesimulator/UIPageViewControllerDemo.build/Objects-normal/i386/fmdb.o and /Users/wostler/Library/Developer/Xcode/DerivedData/UIPageViewControllerDemo-hjsgatcuhsxeokdnubifybpivzum/Build/Intermediates/UIPageViewControllerDemo.build/Debug-iphonesimulator/UIPageViewControllerDemo.build/Objects-normal/i386/main.o
Please dont mark this as duplicate I am getting this error while debugging my
Can anyone explain why I'm getting this compile error? Duplicate 'Rad.Core.Aop.MethodArgumentValidation' attribute E:\Scripting\Rad.Core\Properties\AssemblyInfo.cs This
I am getting an error like this: [WARN]Warning: Multiple build commands for output file
I'm using postgres and I'm getting the duplicate key error when updating a row:
Possible Duplicate: Error: No previous prototype for function. Why am I getting this error?
I am getting a ERROR: duplicate key value violates unique constraint users_pkey Detail: Key
Possible Duplicate: Fatal error: Cannot use object of type stdClass as array in Please
Possible Duplicate: Syntax error while defining an array as a property of a class
Possible Duplicate: pthread Function from a Class I am getting an error (Can not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.