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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:17:37+00:00 2026-05-16T20:17:37+00:00

main file (prog.c): #include log.c #include library.c static char * Foo; If some variable

  • 0

main file (prog.c):

#include "log.c"
#include "library.c"
static char * Foo;

If some variable (char * Foo) is defined in main file (prog.c), and it is required by log.c function called from library.c, how to correctly declare Foo to be visible from log.c’s namespace?

  • 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-16T20:17:37+00:00Added an answer on May 16, 2026 at 8:17 pm

    It is aconventional to include the library source code in your main program:

    #include "log.c"
    #include "library.c"
    static char * Foo;
    

    (The semi-colon is needed.)

    However, given that is what you are doing, if “log.c” needs to see the declaration, you could simply do:

    static char * Foo;
    #include "log.c"
    #include "library.c"
    

    Now the static declaration is visible to “log.c” (and “library.c”).

    If you go for a more conventional setup, then you would have the code in “log.c” access a global variable declared in an appropriate header (rather than a file static variables). However, such dependencies (where a library file depends on a global variable) are a nuisance. The main program (or some piece of code) has to provide the variable definition. It would be better to have the code in “log.c” define the variable, and the (presumed) header “log.h” would declare the variable, and then the main program would set the variable accordingly. Or, better, the code in “log.c” would provide a function or several functions to manipulate the variable, and the header would declare those functions, and the main program would use them.

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

Sidebar

Related Questions

my main file is <div id=man> //some content <div id=one> //some content <div id=two>
In my main file I have an array of character strings, char names[320][30], and
I'm developing web page which has main file index.php as follows: include('UserClass.php'); include('html/top.php'); $user
My Lex file main.l : %{ #include <stdio.h> %} %% start printf(Start command received\n);
int main() { FILE *read_fp; char buffer[BUFSIZ + 1]; int chars_read; memset(buffer, '\0', sizeof(buffer));
My main HTML file dynamically loads in content with; <html> <head> <script src=http://code.jquery.com/jquery-1.7.1.min.js></script> </head>
Below is my main activity file. I am stuck with the bottom area (commented
I write two file main.php and download.php . main.php echo<form action='download.php' method='post'> for(i =
In my main CSS file, I have my a:link selector set to display links
In my layout file - main.xml(linear layout), there are 2 buttons(say b1 and b2),

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.