linkage

Linkage Error with Inherited Class

I have static library and another program which uses it. In the static library If I define header without inheretence it works fine. class TcpCommunication On the other hand If I use inheretence with a QT class, class TcpCommunication:public QTcpServer I'm getting linkage error when I compiling code which uses this static library...

Howcome some C++ functions with unspecified linkage build with C linkage?

This is something that makes me fairly perplexed. I have a C++ file that implements a set of functions, and a header file that defines prototypes for them. When building with Visual Studio or MingW-gcc, I get linking errors on two of the functions, and adding an 'extern "C"' qualifier resolved the error. How is this possible? Header f...

c++ static won't link

Can you help? The following code: class MT { public: static int ms_number; }; int MT::ms_number; yields: Error 8 error LNK2005: "public: static int MT::ms_number" (?ms_number@MT@@2HA) already defined in ProjName.obj Why? ...

Using Three20 with another library and conflicting linkage flags

I'm trying to add Three20 to my project, but the -ObjC and -all_load flags are messing with another library I'm using. The other library is ZXingWidget for barcode reading, but I don't think that part is relevant. I'm reasonably sure the answer is to use force_load instead of all_load and then point to my three20 libraries, but I can't ...

Internal linkage with static keyword in C

I know static is an overloaded keyword in C. Here, I'm only interested in its use as a keyword to enforce internal linkage. If you have a global variable declared in a .c file, what is the difference between using static and not using static? Either way, no other .c file has access to the variable, so the variable is basically "priva...

Linkage of various const/static variables

I have a few questions about the linkage from the following variables. By examples of 7.1.1/7 of C++03 and experimenting with compilers (Comeau, Clang and GCC), I came to the following linkage kinds: First static, then extern static int a; // (a) extern int a; // (b) valid, 'a' still internal It's clear to me with accordance to sect...

How to define a function to be inline internal and external copy in C99

My library contains a function that is used both internal and external. The function is so small that I want the compiler to try to inline function when called internal. Because the function uses information of an incomplete type external calls cannot be inlined. So my module should also always contain a copy of the function with externa...

Are all functions in the c++ standard library required have external linkage?

So I've got an app which compiles fine on windows, linux and a few variations of unix. I recently decided to port it to OSX when I ran into a snag. I have a template which looks like this: template<int (&F)(int)> int safe_ctype(unsigned char c) { return F(c); } the idea being to prevent sign extension from crashing certain implementa...

Multiple Boost.Thread Instances OK in a C++ application?

I have an application with a plug-in architecture that is using Boost.Threads as a DLL (specifically, a Mac OS X framework). I am trying to write a plug-in that uses Boost.Threads as well, and would like to link in the library statically. Everything builds fine but the application quickly crashes in my plug-in, deep within the Boost.Thre...

How to remove 'ImageList_Read' : inconsistent dll linkage warning ?

When I build my Visual C++ Solution ( 2005), I get the following warnings 1> c:\winddk\7000.0.winmain_win7beta.081212-1400\inc\api\commctrl.h(678) : see previous definition of 'ImageList_Read' 1>e:\xml parse\development\gui\h\wtl4mfc.h(6) : warning C4273: 'ImageList_Write' : inconsistent dll linkage 1> c:\winddk\7000.0.w...

how to make function local to main only

File1.c #include<stdio.h> #include"File2.c" void test(void) { sum(1,2); } int main(void) { int sum(int a,int b); test(); sum(10,20); return 0; } File2.c int sum(int x,int y) { printf("\nThe Sum is %d",x+y); } Now as far as my understanding goes test() calling sum() should give a compile-time error since I ...

Dynamically place instances of MovieClip on stage (AS3)

I'm trying to dynamically place instances of MovieClip on the stage. Receiving an error: TypeError: Error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/addChild() ActionScript: // properties in class ---------- var circle_ary:Array = new Array; var circ_num:int;//...

compilation process in C++

I will be very grateful, if somebody can actually explain what exactly my compiler does when I press button BUILD, and compiler begins to compile all my .h and .cpp files how exactly this process is going on(what do I have inside object file?), why do I ask such question? I'm trying to understand what does it mean "minimize compilation d...

How can I build Qt Application in Qt creator with static links on Windows with VS2008 runtime?

I have downloaded qt-win-opensource-4.7.0-vs2008.exe from nokia site and use it when I build my application. My application realy use VS2008 runtime not MinGW, but it has the dynamic linkage with QtCore4.dll and others Qt libs. How can I create application with static linkage with qt libs? ...

linkage error c++ unresolved external symbol

Hi, I'm writing a Matrix program: I have a class to represent a Regular matrix (RegMatrix), and a class to represent a sparse matrix (SparseMatrix), that is: represent only the none-zero's values. In the begining of each H file, i write the opposite class declaration. For example, in SparseMatrix.h I write class RegMatrix (so that the c...

External linkage

$3.5/2- "When a name has external linkage, the entity it denotes can be referred to by names from scopes of other translation units or from other scopes of the same translation unit." Should not the highlighted 'or' be 'and' or is it just a wrong day for me to interpret some English stuff? An additional question is if the...

extern "C" (C linkage) by default

Question Do GCC, MSVC, or Clang, or some combination support setting linkage to default to C? Background I have a large mixed C/C++ project, and while it's easy and logical to export symbols in the C++ sources with C linkage, those same sources are assuming the stuff in the rest of the project are under C++ linkage. The current situa...

Linkage of class names

$3.5 - "In addition, a member function, static data member, class or enumeration of class scope has external linkage if the name of the class has external linkage." Any inputs on what does it mean by 'if the name of the class has external linkage'? Is the hint on 'local classes' (which probably don't have any linkage) as co...