dlls / templates / #includes etc.

L

Leslaw Bieniasz

Cracow, 15.09.2004
Hi,

I am writing a big C++ project using BCB 4.0. The project
consists of several dlls and exes. Each of the dll
is composed of several units (that is cpp files with corresponding h files)
containing:
1) ordinary C++ classes or functions,
2) class templates or function templates.
I want the code for templates to reside within the dlls,
by using appropriate instantiated template declarations within the
source for the dlls.
The dlls may be called by each other, not only by the exes.

After struggling with many problems my project is currently working,
but I am not fully satisfied and not sure whether I do everything correctly.
In particular, I am not sure about what is the orthodox and most elegant
way of organising the structures of the particular dll subprojects.
I have a permanent difficulty with deciding where (in which files) to
#define all necessary macros like those representing _declspec needed in dlls,
which files to #include and where, and where and under which conditions
to place the instantiated template declarations. Furthermore, I often
have an additional complication resulting from the cross-use of classes
(for example a class template A calls methods of the class template B
by a pointer to B kept in A, and simultaneously class template B calls
methods of class template A by a pointer to A, kept in B), which makes
troubles if the various files are not properly #included. Finally,
I am not sure how to set up a header file for a dll, that will
be #included in calling dlls or exes. Should it contain a list
of #includes of all header files to be exported?
Among other things, I would like to avoid unnecessary #includes and make
the compilation sequence more transparent and efficient.

Can anyone supply me with a complete explanation of how all the above
should be done properly?

Sincerely,

L.B.

*-------------------------------------------------------------------*
| Dr. Leslaw Bieniasz, |
| Institute of Physical Chemistry of the Polish Academy of Sciences,|
| Department of Electrochemical Oxidation of Gaseous Fuels, |
| ul. Zagrody 13, 30-318 Cracow, Poland. |
| tel./fax: +48 (12) 266-03-41 |
| E-mail: (e-mail address removed) |
*-------------------------------------------------------------------*
| Interested in Computational Electrochemistry? |
| Visit my web site: http://www.cyf-kr.edu.pl/~nbbienia |
*-------------------------------------------------------------------*
 
T

Thomas Matthews

Hartford, 15.09.2004

Leslaw said:
Cracow, 15.09.2004
Hi,

I am writing a big C++ project using BCB 4.0. The project
consists of several dlls and exes. Each of the dll
is composed of several units (that is cpp files with corresponding h files)
containing:
1) ordinary C++ classes or functions,
2) class templates or function templates.
I want the code for templates to reside within the dlls,
by using appropriate instantiated template declarations within the
source for the dlls.
The dlls may be called by each other, not only by the exes.
1. Dynamic Linked Libraries (DLLs) and Executable programs (exes)
are not a part of the C++ language, but produced from
translating the source code. Thus they are not topical on this
newsgroup.

2. Templates are stencils. The code generated for them is only
generated when they are instantiated. Worst case, each stencil
produces its own blocks of code. There is no code generated
for templates that are not instantiated.

3. Libraries and executables are generally separate projects. If their
source codes share templates, the code for the template will be in
the project as it is instantiated. Most likely, there will not be
common code between a library's instantiation of a template and
and executable's instantiation of a template.

4. Consider libaries as separate projects. Libraries should be
self-contained. They should have all the data, variables and code
that they access. Libraries should not execute code in executables
nor in other libraries (unless this practice is extremely well
documented).

More details can be found in a newsgroup about your platform, tools or
in

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top