 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Lokicer Guest
|
Posted: Mon Feb 28, 2005 5:25 am Post subject: How protect source code in template library? |
|
|
Hi!
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?
Thanks!
|
|
| Back to top |
|
 |
Jack Klein Guest
|
Posted: Mon Feb 28, 2005 6:39 am Post subject: Re: How protect source code in template library? |
|
|
On Mon, 28 Feb 2005 13:25:39 +0800, "Lokicer" <lokicer (AT) 163 (DOT) com> wrote
in comp.lang.c++:
| Quote: | Hi!
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?
Thanks!
|
Then don't distribute your code with template classes. Provide
binaries of pre-compiled classes only with header files. Be prepared
to produce many different versions for different operating systems,
compilers, and even versions of the same compiler.
Or select another language. C++ is not particularly designed for
this.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
|
|
| Back to top |
|
 |
Ivan Vecerina Guest
|
Posted: Mon Feb 28, 2005 8:13 am Post subject: Re: How protect source code in template library? |
|
|
"Lokicer" <lokicer (AT) 163 (DOT) com> wrote
| Quote: | 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
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|