|
I doubt it. The only way to know is to actually test it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What is linkage and what is use of internal linkage and external linkage?
rajesh
|
|
|
|
|
The notion of linkage is kind of complicated because the word describes code properties that can be understood within several different contexts.
The most obvious is referring to the compiling process when the LINKER is invoked to supply code linking the object files in your project to another existing external binary Library (typically a DLL) of funtions and resources.
Another distinct context for the term 'linkage' involves the using terms like 'extern' preceeding function prototypes being imported via P/Invoke, or Interop, (unmanaged code being inserted into a managed environment). This merely prevents the Visual Studio compiler from managling the name of the function. This is referred to as 'specifying linkage'.
I frankly hate the language that Microsoft engineers use to describe their technologies. It can be, and often is, confusing as hell.
I suggest you be more specific about the context in which the term is being used. In this case, I have described only two of possibly a dozen or more conventional usages.
But, generally speaking, internal linkage is similar to execution scope, and external linkage refers to separate compiled binary entities and dependencies in other programming languages or compiled by other vendor compilers.
You might find this article helpful:
Mixed Language Programming and External Linkage[^]
|
|
|
|
|
hi,
Can I take or compute tahe address of register variable?
can I make register variable as global or static?
Please let me know reason.
rajesh
|
|
|
|
|
Do you mean a location in the registry ? No. If not, what do you mean ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
No, you can't take the address of a register variable - after all, what would its address be if it's in register?(!!) For the same reasons such vars cannot be static nor global.
|
|
|
|
|
Sorry, I should correct the last post, in ANSI C you can't take the address of an register var, in C++ you can. If you take the address of a register var, the compiler will place it in memory anyway.
Remember it's up to the compiler to decide which vars are placed in registers, so the register storage modifier is only a hint.
You cannot make such vars global or static.
|
|
|
|
|
I was wondering if somebody could tell me how self registering objects work when we use a anonymous namespace and static keywords. Is the registration done during compile time or run-time??
So, if i declare
//Create an Anonymous for the factory to self register frame classes, also such that the scope is limited to this file preventing the compiler from getting confused with methods of other frame types
namespace
{
Frame* createIFrame()
{
return new IFrame;
}
int FrameType = 1;
bool registered = FrameFactory::Instance()->registerFrameFn(1,createIFrame);
}
this code is inserted into the .cpp file of every class that is added new, how does the object registration occur without ever being called explicitly??
|
|
|
|
|
A method in an anonymous namespace is visible only to the cpp file in which it is written. It cannot be called from anywhere else.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The code sample is taken from Modern C++ Design by Andrei Alexandrescu. It works fine, registering the classes during compile time, why it works I do not understand. As you an anonymous namespace inside a cpp files that has the class definition,cannot be called externally.
But this method is called by ClassName::register and works fine.
|
|
|
|
|
I'm not sure I understand the scope of the code in question, but I suspect that Koenig lookup is the reason, if you're saying what I think you're saying.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think I did not phrase my question properly, let me try again:
factory.h
class Factory
{
.......
}
Rectangle.cpp //This implements the rectangle class, and will register itself with the factory
namespace
{
Shape *createRectangle()
{
return new Rectangle;
}
Factory::Instance()->registerShape(rect_id);
}
main.cpp
int main
{
Shape *s
s=Factory::Instance()->createShape(rect_id)
}
Factory is a singleton and Instance is the single point of entry. The part I do not understand is this, there is no explicit call to registerShape, it is inside the anonymous namespace. Every new shape will just include similar code to the one in the namespace, and by some compiler magic all these new shapes will get registered with the Factory with their id.
What exactly is the compiler magic, that register each new shape, does this happen dynamically or at compile time?
|
|
|
|
|
I think I did not phrase my question properly, let me try again:
factory.h
class Factory
{
.......
}
Rectangle.cpp //This implements the rectangle class, and will register itself with the factory
namespace
{
Shape *createRectangle()
{
return new Rectangle;
}
Factory::Instance()->registerShape(rect_id);
}
main.cpp
int main
{
Shape *s
s=Factory::Instance()->createShape(rect_id)
}
Factory is a singleton and Instance is the single point of entry. The part I do not understand is this, there is no explicit call to registerShape, it is inside the anonymous namespace. Every new shape will just include similar code to the one in the namespace, and by some compiler magic all these new shapes will get registered with the Factory with their id.
What exactly is the compiler magic, that register each new shape, does this happen dynamically or at compile time?
|
|
|
|
|
What do registerShape and createShape look like ? I can't see how this would work, either. There is no compiler magic to make methods call themselves.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hello can any body tell me whether there is ne library in c++ using which i can display a jpg image in c++ output window.or send me ne code for this program.
thanx
|
|
|
|
|
http://www.codeproject.com/bitmap/cximage.asp
|
|
|
|
|
Hi all,
I'm trying to show a form using show but I'm getting some odd behaviour. Here's the code,
<br />
SplashScreen* splash = new SplashScreen ();<br />
splash->Show ();<br />
<br />
if ( ! BCM->ValidateConfigurationFile () )<br />
{<br />
return 0;<br />
}<br />
else<br />
{<br />
if ( BCM->RunLoginScreen () )<br />
{<br />
Application::Run ( new NetworkView ( BCM->getAccessLevel () ) );<br />
}<br />
return 0;<br />
I want the splash form to stay open until it is closed in the RunLoginScreen () method. The form however doesn't open until the login method opens a login screen. Can anyone tell me why I'm getting this behaviour.
Thanks in advance guys.
|
|
|
|
|
Right, new probelm.
Apparently it wasn't a problem with the show method, it's a problem with the pictureBox. I can't seem to use a pictureBox whilst using the form->Show () method. If I use ShowDialog () then alls good but this isn't what I need to do.
Does anyone have any idea why I can't use, or more correctly, why my pictureBox images won't show when I use form->Show (); Or an alternative way to go.
|
|
|
|
|
Given the declaration. int *a; The statement. a = new int [50]; Dynamically allowcates an array of 50 components of the type?
int, int*, pointer, address?
|
|
|
|
|
You get a pointer to an array of 50 unique integers.
|
|
|
|
|
int* a; declares a as a pointer to an int .
a = new int[50] allocates an array of 50 int , and then returns the address of the array in memory into a.
then, you can code a[1] to access the 2nd cell on the array.
if you wanted an array of pointers to int, you should write this :
int* a;
a = new int*[50];
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Not quite. That would be:
<br />
int **a = new (int *)[50];
<br />
int *b = a[0];
<br />
int c = 0;
<br />
b = &c;
<br />
a[0] = &c;
<br />
*b = 5;
<br />
*(a[0]) = 5;
(Note: I wrote this code in the input box and didn't compile it to double-check if it works, so if I got something wrong please correct me.)
Like the other posters said, the code "int *a = new int[50]" allocates an array of 50 integers on the heap and assigns a to the address of the beginning of that array.
|
|
|
|
|
Thank You very much I wish I would of found this site Last year because I Graduated today from Farmingdale suny I thank all comrades of this site Thank You
|
|
|
|
|
Question:
typedef void (* FUNCTION_PTR) (float*, float**); //.h
float InArray[10];
float* OutArray[5];
float first_element, second_element;
(*FUNCTION_NAME)(InArray, OutArray); //Calls the function
OutArray_first_element=??????????????//how do I access Out Array elements?
OutArray_second_element=????????????//how do I access Out Array elements?
Thanks, Mike
|
|
|
|
|
OutArray[0][0] gets the first element.
OutArray[0] gives you the first array, then the second [0] indexes it. You have an array of arrays there. The real question is how do you know the dimensions.
Christian Graus - Microsoft MVP - C++
|
|
|
|