473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Tell me why the symbol "_" use in the Library?

Tell me why the symbol "_" use in the Library?

For example,

char *_itoa( int value, char *string, int radix );

But We use function "itoa(value,string,radix) "only.

I want to know the specific reason .
Nov 14 '05 #1
4 2423
>Tell me why the symbol "_" use in the Library?
For example,
char *_itoa( int value, char *string, int radix );
But We use function "itoa(value,string,radix) "only.
I want to know the specific reason .


_itoa() is not a standard C function. On the other
hand, itoa() isn't either.

Gordon L. Burditt
Nov 14 '05 #2
On Tue, 29 Mar 2005 10:59:12 +0900, "±èµ¿±Õ"
<na*******@game.hs.kr.NOSPAMOK> wrote:
Tell me why the symbol "_" use in the Library?

For example,

char *_itoa( int value, char *string, int radix );

But We use function "itoa(value,string,radix) "only.

I want to know the specific reason .

Function names beginning with _ and a lower case letter are reserved
for the implementation. Therefore, the compiler writer can be
reasonably certain that you will never create a function with that
name. This avoids name conflicts.
<<Remove the del for email>>
Nov 14 '05 #3
In article <d2**********@news1.kornet.net>,
±èµ¿±Õ <na*******@game.hs.kr.NOSPAMOK> wrote:
Tell me why the symbol "_" use in the Library? For example, char *_itoa( int value, char *string, int radix ); But We use function "itoa(value,string,radix) "only. I want to know the specific reason .


This is a matter which is dependant on the library implimentation and
upon the operating system library format and link procedures.

This topics are not generally considered to be "on topic" for
comp.lang.c as people here usually prefer to only talk about matters
which are standardized by one of the C standards.

You do not mention which operating system you are using, so we are
unable to make specific comments about why your particular system
choose that particular convention (and we probably do not personally
know the people who wrote your operating system in order to write them
and ask for "specific" reasons.)
The best I can do at the moment (other than to refer you to a newsgroup
more specific for your OS) is to comment on a -particular- OS that
uses that particular scheme.

In that particular OS, the OS creators provided mechanisms to
allow users to link routines with the same name as system
library routines. For example, it is often useful to link in
different versions of the code related to malloc() -- e.g., debugging
versions, or versions that use "pools" of fixed blocksize for
efficiency, or versions that allocate from shared memory so that
the memory can be easily given back to the operating system.

Allowing users to use their own versions of routines can become
a bit tricky, especially if you want the users to be sure they
can get at the original, system provided versions. The mechanism
chosen in the -particular- OS I am thinking of, was to use
a system of "strong" and "weak" symbols in libraries. By default,
all symbols in user-compiled code are "strong" symbols. When
the implimentation of a "strong" symbol is linked in, this particular
OS uses it and silently supresses all warnings about overlap with
the "weak" version of the same symbol. If, though, no "strong"
implimentations are linked in, then this linker silently promotes
the first "weak" definition it encountered to become equivilent
to the "strong" version of the symbol, and the linking proceeds.

In this way, if the user provided implimenting code for a
library routine, that implimenting code would be used by the
places in the code that called upon the "strong" symbol, and
the user would not be pestered with warnings about there being
conflicting symbols defined in the library. (This is useful
particularily for symbols which are -not- part of the C standard,
but might be part of some other standard that the user doesn't
happen to be choosing to employ at the time.) But if the user
did not provide an implimentation, then the library version of the
routine would get used. And anywhere that explicitly called
upon the weak symbol (such as from within the other modules of
the system library routines which count on things being done
just the way they expect) then those references would go to the
system routine, not to the user routine.
The convention that the implimenters of this scheme chose was
to name the weak symbol with a leading underscore; then,
to find the corresponding name of the strong symbol in order
to promote the weak symbol to a strong one, all that had to be done
was to remove the leading underscore.

Why an underscore? There are different possible reasons.
Double-underscore was reserved in some contexts. Any particular
alphabetic might have conflicted with a user-defined name.
The library code was often itself written in C, and numbers
are not valid at the beginning of C routine names, so leading
digits could not be used. THe only non-alphabetic non-digit
symbol that is accepted by the C standard as the leading character
in a routine name is underscore. The implimenters could perhaps
have chosen some system such as underscore followed by a digit
for the weak symbols, but at the time it was still important to keep
external identifier names short (especially for use with
Fortran), so a single underscore was the easiest choice.
--
This signature intentionally left... Oh, darn!
Nov 14 '05 #4
Bob
On 29 Mar 2005 05:02:34 GMT, ro******@ibd.nrc-cnrc.gc.ca (Walter
Roberson) wrote:
In article <d2**********@news1.kornet.net>,
±èµ¿±Õ <na*******@game.hs.kr.NOSPAMOK> wrote:
Tell me why the symbol "_" use in the Library?
...
I want to know the specific reason .


This is a matter which is dependant on the library implimentation and
upon the operating system library format and link procedures.
...
external identifier names short (especially for use with
Fortran), so a single underscore was the easiest choice.


Amen.

Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rodolphe | last post by:
Hello, I'm French so sorry for my approximate English. When I try to compile a project under Visual C++ 6.0, I've got the following errors : applicap.obj : error LNK2001: unresolved external...
2
by: Gianni Mariani | last post by:
I'm getting "multiply defined" errors on STL symbols. Isn't this a linker error ? By definition, doesn't the compiler/linker need to guarentee the "one definition rule". Linking... ...
1
by: Michael | last post by:
Hello dear .Net experts I have created a Visual C++ class library (.net) project with two classes named Base and Derived wher Derived inherits from Base. When I add a destructur to base I get the...
1
by: Awin | last post by:
Hello all, I'm a beginner of COM programming, I have a exercise, but got a compile error with ComFortuneTeller.obj : error LNK2001: unresolved external symbol _IID_IQuotation...
3
by: Kenneth Kahl | last post by:
Hello, I would like to call a C++ programm out of Java with help of JNI. By the followed command I created a "shared library": g++ -shared -o libcalculate.so rechner.cpp When I create an...
15
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal...
1
by: =?Utf-8?B?TWF0ZXVzeiBSYWpjYQ==?= | last post by:
Hi! How can I fix this error? Error 1 error LNK2001: unresolved external symbol "extern "C" long __stdcall SHFlushClipboard(void)" (?SHFlushClipboard@@$$J10YGJXZ) UnmanagedTest.obj Basically...
8
by: amievil | last post by:
Hello. I'm devloping MFC program and found something weird happening. When I compile it with "debug mode", it compile fine, and runs fine. however, when I compile with "release mode", I get...
7
by: JustBeSimple | last post by:
Hi Everyone, I'm having a problem compiling useing the VS2005 .NET I need help to resolve those error, I try to create a new project it doesn't help any suggestion? I got the following errors:...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.