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 8884583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:05:43+00:00 2026-06-14T21:05:43+00:00

Possible Duplicate: obj-c duplicate symbol for header variable I have multiple .m and .mm

  • 0

Possible Duplicate:
obj-c duplicate symbol for header variable

I have multiple .m and .mm files in my project. I can include this .h file (that dosent have a corresponding .m or .mm file) in as many .m files as I like but when I include it in more than one .mm file I get the duplicate symbols linker error.

Also in the .h file I have surrounded the content with preprocessor commands (Are these respected in obj-c?) here is what it mostly looks like:

#ifndef _CONFIG_H_
#define _CONGIF_H_

CGFloat WIDTH, HEIGHT;
// other similar code...

#endif

I get the duplicate symbols error on WIDTH and HEIGHT

  • 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-06-14T21:05:44+00:00Added an answer on June 14, 2026 at 9:05 pm

    You should add

    extern
    

    keyword before CGFloat declaration in the header, and define the variables without extern in the .m file to avoid defining your variables in multiple places.

    In the header:

    extern CGFloat WIDTH, HEIGHT;
    

    In a .m file (one of them, any one)

    CGFloat WIDTH, HEIGHT;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why can templates only be implemented in the header file? “Undefined symbols”
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Obj-C, how can I append one NSMutableArray to another? I want to
Possible Duplicate: How to break outer cycle in Ruby? say I have this code:
Possible Duplicate: Length of Javascript Associative Array I have a JSON that looks like
Possible Duplicate: Using a variable for a Javascript object key I can't figure out
Possible Duplicate: Javascript - array.contains(obj) What's wrong with this: var zipCodes =(['90001','90002','90003']); Test if
Possible Duplicate: static , extern , const in header file I am working in
Possible Duplicate: How to code a modulo (%) operator in C/C++/Obj-C that handles negative

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.