Notification texts go here Contact Us Buy Now!

C_programming: Static_function_Problem

#include "B.c"
You include the C file so there is only one compilation unit and static functions are visible in this unit. Basically, the content of the file B.c is inserted into the A.c file and the compiler is compiling one file.

we change the storage class to static

It is not the storage class, only the linkage. static functions do not have external linkage. To get the behavior required (i.e., unresolved symbols), you need to have two separate compilation units, and after the compilation, they have to be linked together. In your example, remove the #include "B.c" and it will stop to link. Generally, never include '.c' files or define functions or data in the header files.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.