473,699 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!
Jul 23 '05 #1
2 3186
On Mon, 28 Feb 2005 13:25:39 +0800, "Lokicer" <lo*****@163.co m> wrote
in comp.lang.c++:
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.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 23 '05 #2
"Lokicer" <lo*****@163.co m> wrote in message
news:cv******** **@mail.cn99.co m...
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
incompatibiliti es 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
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4020
by: mosfet | last post by:
I have a question I would like to developp an app in .NET but I would like to keep my source code secret. However since anyone can decompile a binary to find the source code (http://www.remotesoft.com/salamander/) how am i supposed to do ? I have already used a java decompiler and it's amazing to see that you can have the source code of any .class so if it works as well for .NET I am a bit worried.
4
1296
by: Cablito | last post by:
Is there a way to protect my class libraries? I have for instance, a class library full of my base forms and classes latter inherited by various projects. A lot of logic is within those objects and I´d hate to see other companies or individuals being able to add my DLLs to their .NET solution and using it at will.
4
3005
by: jack | last post by:
Hi there, I have a short question about template function definition. 1) The following files will not compile in M$ VC++ but will have no problem with g++. 2) However, if I uncomment all comments in all three files, then it is ok in both compilers.
4
1317
by: Steven T. Hatton | last post by:
Are the Standard Headers as described in ISO/IEC 14882:2003 available in source file form as they appear in the standard? What I mean by this is, for example §20.4 describes the Header<memory> and contains segments of C++ code such as the following: namespace std { // 20.4.1, the default allocator: template <class T> class allocator; template <> class allocator<void>; template <class T, class U>
15
5078
by: Fady Anwar | last post by:
Hi while browsing the net i noticed that there is sites publishing some software that claim that it can decompile .net applications i didn't bleave it in fact but after trying it i was surprised that i could retrieve my code from my applications after i compile it so i need to know to prevent this from happening to my applications Thanx in advance
3
2424
by: Ganesh Muthuvelu | last post by:
Hi, I have a ASP .NET application that we give to our clients for them to deploy it in their web server and use it. My concern is that all of my ASPX pages source code is open and our clients can open the ASPX file and see the code in it. I want to protect my code something like a Windows application where we give only the .EXE and the dll's. Is there a way to do the same for ASP .NET applications
2
13529
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to execute a MailMerge to create mailing labels or customized letters. A label name known to MS Word MailMerge mailing label wizard may be used or a template file containing the field names Line1 thru Line5 for each record to be printed. If a...
3
1914
by: yservel | last post by:
Hi everybody. I was just wondering how did editors were protecting their source code from decompilers and reverse engeneering. I heard one method of source code protection was by obfuscation: http://en.wikipedia.org/wiki/Obfuscated_code Does every editor use Obfuscation? How does large software editor like Microsoft protect their source code? Do they manage to protect their source code?
2
4203
by: clintonb | last post by:
I'm using: Microsoft Visual Studio 2005 Version 8.0.50727.42 Issue 1: We have a solution with a web project and some class library projects. The web project references the class library projects via a project reference. Whenever we compile the class library projects, their dlls are added to the bin folder of the web project. Visual Studio wants to add
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.