I'm just wondering why some functions in certain apps/os's have a leading _ (underscore) in there names.
i.e. int _out_char(unsigned char c)
Leading "_" In Function Names
Re:Leading "_" In Function Names
Because the author of the code likes underscores.
Technically, the C standard dictates that the only identifiers that can begin with an underscore are vendor-specific extensions to the C libraries. For example, the Microsoft C runtime library defines a few Posix functions (open, read, close etc.). Because the declarations for these functions are contained in the standard C header files, they must start with an _. The reason for this is that any conforming C program is free to use any non-standard name for itself as long as it doesn't start with an _. So if the library starts definining non-standard functions that don't have an _ at the start, there's a chance that they could clash with a perfectly legal identifier in somebody's program.
As the author of the C runtime, you should follow this for maximum compatibility with standard C programs. If you put any non-standard things in the headers, put an _ at the start of the name.
As the author of C programs, you should follow this too. Don't put an _ at the start of any of your identifiers. C++ is even more strict: it prohibits you from using any identifier with __ in it.
Technically, the C standard dictates that the only identifiers that can begin with an underscore are vendor-specific extensions to the C libraries. For example, the Microsoft C runtime library defines a few Posix functions (open, read, close etc.). Because the declarations for these functions are contained in the standard C header files, they must start with an _. The reason for this is that any conforming C program is free to use any non-standard name for itself as long as it doesn't start with an _. So if the library starts definining non-standard functions that don't have an _ at the start, there's a chance that they could clash with a perfectly legal identifier in somebody's program.
As the author of the C runtime, you should follow this for maximum compatibility with standard C programs. If you put any non-standard things in the headers, put an _ at the start of the name.
As the author of C programs, you should follow this too. Don't put an _ at the start of any of your identifiers. C++ is even more strict: it prohibits you from using any identifier with __ in it.