Questions about the standard C library

Asked

Viewed 75 times

0

I noticed that the header file (.h) are different in different compilers. So I have the doubt, is that this "C ANSI pattern" just defined which functions should have the standard library and not wrote them. Or if these compilers are not standard, and so they themselves defined these files (.h).

Analyzing the header files I noticed the absence of the command extern, and I don’t understand why this, after all these functions (printf(), puts(), etc.) are set in binary files, ie should have something written as extern int printf(const char*, ...), or similar. Why command extern is absent?

  • The issue of extern seems to be another different question and one that would need to show better about.

2 answers

3

The default defines the specification, each does as you want the implementation. As long as the implementation complies with everything that is in the specification it can do as it wishes and will conform to the standard. It can even do much more. Of course there is a risk that one day it will be specified in another way and he will have to abandon what he created in favor of what was specified to conform to the standard.

Compilers generally want to be within the standard, but there are some less known that are not. It is practically considered a compiler of another language similar to C, but is not C itself.

  • What about the extern, has any explanation or recommendation of any website that explains?

  • @Filipe_br No, but if you ask another question about it, I can try to see, or maybe someone else can answer. But put it where you saw it in a way, what way you think it should be, and why you think it is. Then a good answer can come.

1


I stopped to think about the absence extern and I came to a conclusion. This has to do with the concept of modularization. Know when you create a file (.h) and another (.c) and both have the same name, what ta in the file (.c) is accessible by (.h), even without using the extern. And the same happens for example with a file my_file. h and my_file.lib.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.