Re: How protect source code in template library?

From: Ivan Vecerina (INVALID_use_webform_instead_at_vecerina.com)
Date: 02/28/05

  • Next message: john townsley: "vector"
    Date: Mon, 28 Feb 2005 09:13:31 +0100
    
    

    "Lokicer" <lokicer@163.com> wrote in message
    news:cvua3b$974$1@mail.cn99.com...
    > I am a newbie in C++, it seems compiler must see the source code of
    > template classes(with .h files and .cpp files£©when compile. I want to
    > prevent others from getting .cpp files. How should i do?

    To instantiate template code for new (user-provided) data types,
    the compiler does need to see the template source code (which
    is commonly left into .h files). You can't get around that,
    but your template code could be a thin layer around non-template
    code (stored in .cpp files) that you distribute into a
    compiled library.
    It is common enough for proprietary C++ libraries to be
    distributed as, e.g. on Windows, .h files and a .lib+.dll
    compiled library (NB: this is OT here, ask on a platform-
    specific newsgroup).

    When you do that, you need to be aware potential
    incompatibilities among C++ compilers on some platforms
    (while the way to call C-style functions is pretty much
    standardized everywhere, on some operating systems/processors
    classes/overloaded functions/etc can be implemented in
    incompatible ways -- different "ABI"s).
    This is probably what Jack Klein was thinking about.

    Besides that, C++ is actually among the languages that
    are the more difficult to reverse-engineer from compiled code.

    Ivan

    -- 
    http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
    

  • Next message: john townsley: "vector"

    Relevant Pages

    • Re: Preprocessor, nested files etc.
      ... > then those macro definitions don't seem to stick. ... it takes around 2 hours for a complete recompile). ... When the compiler compiles a *.cpp file, it starts in a fresh state. ... because it means it can compile a collection of *.cpp files ...
      (comp.lang.cpp)
    • Re: classes, strings, learning in VS.NET
      ... The class implementation goes into the .cpp file. ... for C++ compiler. ... .cpp files is completely independent from each other. ... include file is included twice within the same translation unit. ...
      (comp.lang.cpp)
    • Re: newbie question
      ... You need to do the include anywhere you want to reference the variable, ... front of the declaration so the compiler knows it's created elsewhere. ... I have a source file called complx.cpp. ... Both .cpp files are in my project. ...
      (microsoft.public.vc.ide_general)
    • Re: Internal Complier Error in VC++ 1.52
      ... You may have hit some brick wall in the compiler. ... I am working on an existing code base where the no of lines is around 100,000, spread across different header and cpp files. ... when i was trying to add a new function declaration for an existing class in a header file and function implementation in the .cpp file i am getting an error as given below ... CL returned error code 2. ...
      (microsoft.public.vc.mfc)
    • Re: VC++ Compiler issue
      ... > My case might fit in "moderately complicated template code" that you ... > If you have any idea why the compiler is producing an error message, ... >>> I am trying to migrate a Linux project to a Windows project. ... >>> Duke ...
      (microsoft.public.vsnet.general)