Hi,
I read that identifiers should not start with an underscore in order to
prevent LINKAGE problems. I am not familar with this concept of "linkage",
so can someone provide a simple explanation?
Thanks in advance
WD
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 5 2794
In article <3f********@new s.iprimus.com.a u>,
Web Developer <no****@hotmail .com> wrote: I read that identifiers should not start with an underscore in order to prevent LINKAGE problems.
The strongest argument is that there are rules in the standard
that in a nushell say such names are only available for implementors,
in other words, for your compiler or library vendor.
I am not familar with this concept of "linkage", so can someone provide a simple explanation?
Generally speaking, linkage applies to names of entities and
is one mechanism whereby implementations can disabmiguate their use.
In particular, when it needs to resolve where to uses of a name
refers to the same name. For instance, in external linkage,
the use of a "global" name in one translation unit (say a source file)
is considered to be the same name used in another translation
unit that will be linked together. It ties into scope and some
other things too. There is also static linkage and no linkage.
You should get a good C++ text and check out the section that
apply to this topics you raise in this email. Check out http://www.comeaucomputing.com/booklist as one starting point.
--
Greg Comeau/ 4.3.0.1: FULL CORE LANGUAGE, INCLUDING TC1
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
In article <aj************ ************@ne wssvr10.news.pr odigy.com>,
Thomas Matthews <Th************ **************@ sbcglobal.net> wrote: On one hand, there is no restriction against using symbols with leading underscores... .
I think you mean trailing?
--
Greg Comeau/ 4.3.0.1: FULL CORE LANGUAGE, INCLUDING TC1
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Greg Comeau wrote: In article <aj************ ************@ne wssvr10.news.pr odigy.com>, Thomas Matthews <Th************ **************@ sbcglobal.net> wrote:
On one hand, there is no restriction against using symbols with leading underscores.. ..
I think you mean trailing?
No, I meant leading. A C++ compliant compiler will not generate
an error for the following line:
int __my_var;
provided that the defined variable doesn't exist as a public
symbol in the compiler's internals.
However, there may be a problem with the following definition:
int __FILE__;
Because __FILE__ is used by the compiler (actually the preprocessor).
--
Thomas Matthews
C++ newsgroup welcome message: http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq: http://www.raos.demon.uk/acllc-c++/faq.html
Other sites: http://www.josuttis.com -- C++ STL Library book
In article <5X************ ************@ne wssvr10.news.pr odigy.com>,
Thomas Matthews <Th************ **************@ sbcglobal.net> wrote: Greg Comeau wrote: In article <aj************ ************@ne wssvr10.news.pr odigy.com>, Thomas Matthews <Th************ **************@ sbcglobal.net> wrote:On one hand, there is no restriction against using symbols with leading underscores. ... I think you mean trailing?
No, I meant leading. A C++ compliant compiler will not generate an error for the following line: int __my_var; provided that the defined variable doesn't exist as a public symbol in the compiler's internals.
2.10 and 17.4.3.1.2 clearly label this as a restriction.
Of course, certain "errors" need not result in a diagnostic,
but that's a seperate issue.
However, there may be a problem with the following definition: int __FILE__;
Agreed. See above.
Because __FILE__ is used by the compiler
s/used/may be used/
Because __FILE__ begins with two underscores, and Standard C++
reads "Each name that contains a double underscore (_ _) ...
is reserved to the implementation for any use."
(actually the preprocessor).
Perhaps.
--
Greg Comeau/ 4.3.0.1: FULL CORE LANGUAGE, INCLUDING TC1
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it? Web Developer wrote: Hi,
I read that identifiers should not start with an underscore in order to prevent LINKAGE problems. I am not familar with this concept of
"linkage", so can someone provide a simple explanation?
Symbols starting with an underscore are reserved for the compiler or implementation. A programmer's symbol should not start with an underscore to prevent name clashes or conflicts with compiler symbols.
What do you mean by implementation?
WD
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: qazmlp |
last post by:
const has internal linkage in C++, but external linkage in C.
Am I right ?
But, linker reports multiply-defined error if the
following header is included in multiple .cpp files.
// test_const.h
#ifndef HEADER_TEST
#define HEADER_TEST
|
by: Richard Hayden |
last post by:
Hi,
I have the following code:
/******************************** file1.c
#include <iostream>
extern void dummy();
inline int testfunc() {
|
by: Grumble |
last post by:
Hello everyone,
As far as I understand, the 'inline' keyword is a hint for the compiler
to consider the function in question as a candidate for inlining, yes?
What happens when a function with extern linkage is inlined? Should the
compiler still export the function?
Or is an inlined function implicitly static?
|
by: Generic Usenet Account |
last post by:
I am implementing a library that can be linked in with C as well as C++
code. Obviously, the library API is functional, but in my
implementation I am using STL. Because of this, my code is compiled
using a C++ compiler (gcc version 3.3.1). Given the differences in the
way C and C++ code gets linked in, what should I do to ensure that the
C code that links in the library does not give any linker error?
Thanks,
Gus
|
by: Mark A. Gibbs |
last post by:
I have a question about mixing C and C++.
In a C++ translation unit, I want to define a function with internal
linkage and C calling convention. Here's a sample of what I want to do:
// main.cpp
// This is defined in a C module
extern "C" void fake_qsort(void*, std::size_t, std::size_t,
int (*compare)(const void*, const void*));
| |
by: al.cpwn |
last post by:
do static and inline functions or members have internal linkage? I have
been reading this newsgroup on google and found conflicting ideas. Can
someone please help me understand why in some places inline may have
external linkage while in others it has internal (from what I have read
in comments by people). Are there any (other) places where linkage is
ambiguous?
|
by: fctk |
last post by:
source: http://rm-f.net/~orange/devel/specifications/c89-draft.html#3.1.2.2
there are two passages in this paragraph i can't fully understand:
1) "If the declaration of an identifier for an object or a function
contains the storage-class specifier extern , the identifier has the
same linkage as any visible declaration of the identifier with file
scope. If there is no visible declaration with file scope, the
identifier has external...
|
by: catphive.lists |
last post by:
I have a bunch of function object classes of the form
struct MyFunc : unary_function<arg,ret>
{
MyFunc(arg) : state(arg) {}
void operator() (arg) { /*code here*/ }
};
in various cpp files. Now, the problem is that I happen to write two of
these with the same name in different modules that don't know anything
|
by: Bart Simpson |
last post by:
I m getting a ton of linkage errors (unresolved externals) when using an
abstract base class. My classes look something like this:
class BaseObject
{
//pure virtuals
virtual void foo() = 0;
virtual int foobar(int, int, double) = 0 ;
virtual void grok();
|
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 usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |