473,545 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,str ing,radix) "only.

I want to know the specific reason .
Nov 14 '05 #1
4 2435
>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,str ing,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,str ing,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**********@n ews1.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,str ing,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.nr c-cnrc.gc.ca (Walter
Roberson) wrote:
In article <d2**********@n ews1.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
10069
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 symbol _IID_ISampleGrabber applicap.obj : error LNK2001: unresolved external symbol _CLSID_NullRenderer applicap.obj : error LNK2001: unresolved...
2
6882
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... msvcprtd.lib(MSVCP71D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char>...
1
3412
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 following linker error Common.obj : error LNK2001: Unresolved external symbol "void __cdecl __CxxCallUnwindDtor(void (__thiscall*)(void *),void...
1
1502
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 ComFortuneTeller.obj : error LNK2001: unresolved external symbol _IID_IFortuneTeller I don't known what's wrong with my code(I refer to the demo code from "COM/DCOM...
3
19239
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 object from the existing program inside a method of my class rechner.cpp, and then call the method out of java, a following
15
28793
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 System.out.println(i + ": " + sqrt(4));
1
5383
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 I am calling the SHFlushClipboard method from "shlobj.h" (Win32) in a managed c++ app. ~Matt
8
4877
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 a bunch of "unresolved external symbol _imp_FtpFindFirstFileA@20.......blah blah." errors. Can someone explain why this is happening and how to fix...
7
3097
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: vector_main.obj : error LNK2019: unresolved external symbol "public: __thiscall Vector<int>::~Vector<int>(void)" (??1?$Vector@H@@QAE@XZ)...
0
7470
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7405
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7659
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7811
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7760
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5975
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5334
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3455
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.