c++ - using of extern "C" without function -


I book Dale Rojrson "Inside COM" read a chapter 5, He wrote (sorry, I translated into English Is):

extern "c" is for linkage. So has been marked as a function Exile 'C' , not wil compiler, for example, change the function name to another :? CreateInstance @@ YAPAUIUncnown @@ XZ .

It does not explain the obvious to me but uses the author's extern "C" before the other place because:

  Include # lt; Objbase.h & gt; Execution 'C' {// {32bb8320-b41b-11cf-a6bb-0080c7b2d682} Execution Constituency IID IID_IX = {0x32bb8320, 0xb41b, 0x11cf, {0xa6, 0xbb, 0x0, 0x80, 0xc7, 0xb2, 0x82, 0x82} near} ; // {32bb8321-b41b-11cf-a6bb-0080c7b2d682} exile constant IID IID_IY = {0x32bb8321, 0xb41b, 0x11cf, {0xa6, 0xbb, 0x0, 0x80, 0xc7, 0xb2, 0xd6, has 0x82}}; // {32bb8322-b41b-11cf-a6bb-0080c7b2d682} exile constant IID IID_IZ = {0x32bb8322, 0xb41b, 0x11cf, {0xa6, 0xbb, 0x0, 0x80, 0xc7, 0xb2, 0xd6, has 0x82}}; // Extern C ++ is necessary to allocate memory for constants. }   

This is not a function ... Why did the author use extern "C" in this case?

Best regards, Andrey

extern "C" Exile on such a block 'C' is like applying in blocks to make every announcement; It announces the use of C linkage to all of them.

Extern "C" on a non-function extern "C" at a function; It uses object cementics for naming, and whatever is relevant.

For details, you can refer to the standard, section 7.5 linkage specifications [dcl.link] (although it is written using difficulty using English form).


It is possible to bring the language linkage to the institutions declared from a different language. In fact, what it means is dependent on a particular language and C ++ implementation, traditionally with C, it means that symbols and calling conventions are changed for the tasks. As far as I remember, there is nothing different for non-functioning in most implementations. It is only that language specification does not say that you can expect those organizations to work with CU unless you do not use extern "C".

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -