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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:56:26+00:00 2026-05-31T19:56:26+00:00

my test code is below: main1.c: #include <stdio.h> extern struct tt ; int main()

  • 0

my test code is below:

main1.c:

#include <stdio.h>
extern struct tt ;
int main()
{
    struct tt y;
    y.a=255;
    y.b=0;
    printf("tt->a=%#x   ,tt->b=%#x \n",y.a,y.b);
}

main2.c:

#include<stdio.h>

 struct tt
{
    int a;
    int b;
};

makefile:

main: main1.o
    gcc -o main main1.o
main1.o:  main2.c main1.c

but the compiler reports:

cc    -c -o main1.o main1.c
main1.c:2: warning: useless storage class specifier in empty declaration
main1.c: In function ‘main’:
main1.c:5: error: storage size of ‘y’ isn’t known
make: *** [main1.o] Error 1

how do I write code to in a .c file use the struct defined in another .c file ???

thx for your help!

  • 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-31T19:56:28+00:00Added an answer on May 31, 2026 at 7:56 pm

    You need to define the struct in a header file that both .c files include. For example:

    #ifndef __INCLUDE_GUARD_HERE__
    #define __INCLUDE_GUARD_HERE__
    
    struct tt {
      int a;
      int b;
    };
    
    #endif
    

    Now both .c files can #include the header file.

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

Sidebar

Related Questions

Below is my code (test.c): #include <stdio.h> #include <string.h> int main(int argc, char **argv)
I have this code below #include <stdio.h> int main(){ int i=0; for(i=0; i<1000; i++)
I create a file using the code below: #include <stdio.h> #include <stdlib.h> #include <sys/stat.h>
I have the code below in my test code in many places: // //
the code below gives compilation error when I try to create test t[2]; because
When I run a Test Project on Visual Studio I use the code below
In the below code onclick edit how can the value of tag test be
The code looks like below: namespace Test { public interface IMyClass { List<IMyClass> GetList();
The code is as below: <html> <head> <title>test</title> </head> <body> <div><span>shanghai</span><span class=margin> </span><span>male</span></div> </body>
Here's my code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <wait.h> #include <readline/readline.h> #define

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.