Re: question: static objects in LIB

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Mycroft Holmes (m.holmes_at_nospam.it)
Date: 10/21/04


Date: Thu, 21 Oct 2004 14:56:06 +0200


> If "no" How do you assume they (B and C) are using the same lib A?

we have all source code, and we are sure the class they "share" is the same
file.

> Maybe leave A as DLL and make B and C as user of it, is the solution.

yes, but we'd like to know if there's a pure c++ solution (i.e. something in
the language which allows code to be unique. for example: suppose we put in
an header file:

template <typename T>
struct getUnique
{
    static T* Pointer()
    {
        static T t;
        return &t;
    }
}

and then invoke getUnique<MyClass>::Pointer().

since the template function is in a header, the linker has to recompile it
everytime, so shall it avoid duplicates?

-- 
 The set of solutions is never empty.
 Two solutions together form a new problem.
-- Mycroft Holmes


Relevant Pages

  • Compiler error creating managed c++ directx app
    ... I'm trying to create a simple program using managed C++ and DirectX. ... Here is the source code I am using: ... did you forget to include a header file? ... "Microsoft.DirectX" to References in Solution Explorer, ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: [Lit.] Buffer overruns
    ... #defining the symbols within the source code you control you can inhibit ... any preprocessor overrides of those symbols. ... I prefer that the conflict be ... You can even automate it by creating a header file such as define_C.h ...
    (sci.crypt)
  • Re: beginners questions
    ... # (I work on Linux 2.4.22/Debian) ... Some supply the source code, ... second #define converts them into old style K+R function declarations. ... use the same header file for two different styles of compilation. ...
    (comp.lang.c)
  • Re: More on Function Purity
    ... If a function is pure, ... source code) itself. ... Your argument against getArgs is equivalent to arguing that closures ... runprog argv = unsafePerformIO main ...
    (comp.lang.functional)
  • Re: #ifdef
    ... It may be defined by the user, or somewhere in a header file, ... out of a larger context such as the OS source code ... C code after preprocessing but before compiling. ... in tracking down issues with preprocessor symbols. ...
    (comp.lang.c)