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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:05:04+00:00 2026-05-16T06:05:04+00:00

I have two files: hudwidgets.c #include osd.h #include osdadd.h #include <stdio.h> struct TextSize tsize;

  • 0

I have two files:

hudwidgets.c

#include "osd.h"
#include "osdadd.h"
#include <stdio.h>

struct TextSize tsize;
char buff[50];

void hud_draw_lin_compass(int cx, int cy, int tick_maj, int tick_min, int range, int heading)
{
    .. important code that uses buff ..
}

hud.c

#include "hudwidgets.h"
#include "hud.h"
#include "osd.h"
#include "osdadd.h"

.. some code ..

void hud_rc_plane_single_frame()
{
    fill_mem(0x0000);
    if((frame / 50) % 2 == 0)
    {
        get_next_warning(buff);
    }
    .. some more code ..
}

The problem I have is that when I try to compile this, the compiler complains of no buff defined, but when I try to define it, the linker complains of two buff variables. Catch-22. To this end, I am asking two questions:

  1. how to fix this, and;

  2. if it is possible to use the same variable thus saving memory because only one variable needs to be allocated (working with a memory constrained microcontroller.)

  • 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-16T06:05:05+00:00Added an answer on May 16, 2026 at 6:05 am

    You need this in the top of hud.c, and any other .c file you use them from:

    extern struct TextSize tsize;
    extern char buff[50];
    

    The extern keyword tells the compiler that the “actual” variables already exist, in some other unit (file), and the linker will fix it all up for you in the end.

    If you’re doing this on a large scale in a project, consider how you might encapsulate globals in one place, and create a shared .h file that declares these things as “extern” for all the places that you use them from.

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

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Was able to do this by using [myWebView endEditing:YES] May 16, 2026 at 9:38 pm
  • Editorial Team
    Editorial Team added an answer Other answers have given all the good choices, but without… May 16, 2026 at 9:38 pm
  • Editorial Team
    Editorial Team added an answer The INSERT syntax doesn't allow for aliases. Why would you… May 16, 2026 at 9:38 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have two files (f1 and f2) containing some text (or binary data). How
I have two files with slight differences. A normal diff will show me the
I have two files, one is in the webroot, and another is a bootstrap
I have two files in which some of the lines have changed order. I
I have two files which are called version1 version2 Version1 has my own changes,
I have two files where I want to perform union operation based on 1st
I have two files which both contain a list of words. Is there an
I have two files, A is a subset of B. Both A and B
I have two files, in one I declare the variable SEED as such: ;file1.asm
I have two files. main.py that has main program logic and functions.py that has

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.