Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

a simple question in c

Status
Not open for further replies.

a_tek7

Banned
Joined
Feb 9, 2006
Messages
161
Helped
11
Reputation
22
Reaction score
2
Trophy points
1,298
Location
Bandar Abbas
Activity points
0
I want to know that symbol _ in functions of header file has got a specific meaning?
for example _findfirst in dir.h, and why we use this symbol?
tanx
 

devendra_devgupta

Member level 3
Joined
Apr 8, 2007
Messages
54
Helped
3
Reputation
6
Reaction score
0
Trophy points
1,286
Activity points
1,632
hi
I think you must be asking what _ symbol means before any name
for example _INLINE. If this is the question My ans is: this is compiler specific keyword for example
writing _INLINE after any functon will inline that function where ever it is called
 

Ace-X

Advanced Member level 2
Joined
Jan 25, 2002
Messages
529
Helped
41
Reputation
82
Reaction score
14
Trophy points
1,298
Location
Germany
Activity points
5,150
Symbol _ has the same meaning in functions/variable names as for example alphabet symbols. In your case it is just a part of function name. Its specific meaning in your program depends on programmer' mind who wrote this functions, nothing more.
 

svicent

Full Member level 6
Joined
Jul 11, 2001
Messages
322
Helped
33
Reputation
64
Reaction score
7
Trophy points
1,298
Activity points
2,293
The first character of an identifier name must be a nondigit (that is, the first character must be an underscore or an uppercase or lowercase letter). ANSI allows six significant characters in an external identifier's name and 31 for names of internal (within a function) identifiers. The underscore character quickly became established as the primary mechanism for differentiating the external linkage space. It was common practice for C compilers to prepend a leading underscore to all external scope program identifiers to avoid confront with contributions from runtime language support.

Microsoft Specific:

Although ANSI allows 6 significant characters in external identifier names and 31 for names of internal (within a function) identifiers, the Microsoft C compiler allows 247 characters in an internal or external identifier name. Do not select names for identifiers that begin with two underscores or with an underscore followed by an uppercase letter. The ANSI C standard allows identifier names that begin with these character combinations to be reserved for compiler use. Identifiers with file-level scope should also not be named with an underscore and a lowercase letter as the first two letters. Identifier names that begin with these characters are also reserved. By convention, Microsoft uses an underscore and an uppercase letter to begin macro names and double underscores for Microsoft-specific keyword names. To avoid any naming conflicts, always select identifier names that do not begin with one or two underscores, or names that begin with an underscore followed by an uppercase letter.
 

jhbbunch

Full Member level 4
Joined
Feb 21, 2006
Messages
199
Helped
17
Reputation
34
Reaction score
3
Trophy points
1,298
Activity points
2,902
Sometimes a compiler will use _getchar() for the function and then the programmer can define his own getchar() function. It's a cheezy pre C++ way of overloading. You should normally stay away from a leading underscore, whenever I see one, or a double underscore it usually means it is not something written by a programmer, but belongs to a library or is something compiler specific.

Added:

From the C++ language standard:
Code:
17.4.3.1.2
Certain sets of names and function signatures are always reserved to
the implementation:
- Each name that contains a double underscore (_ _) or begins with an
underscore followed by an uppercase letter is reserved to the
implementation for any use.
- Each name that begins with an underscore is reserved to the
implementation for use as a name in the global namespace.


These are rules that are used to minimize name clashing.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top