473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Exporting templates


I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.

I like the "export" feature, whereby I can put template functions in
source files (where I feel they belong -- unless I intend them to be
inline, of course).

I realise, however, that the majority of compilers are defective in that
they do not implement the "export" feature.

I see that the FAQ offers an alternative:

//header.hpp
template<class T>
T Get();

#ifdef UNSUPPORTED_EXPORT_KEYWORD
#include "header.cpp"
#endif
//header.cpp
#ifdef UNSUPPORTED_EXPORT_KEYWORD
#define export
#endif

export template<class T>
T Get()
{
return 0;
}
Do many of you here use this? I'm thinking of starting to use it in my
code. I'm going to put a "readme" file with it saying:

If your compiler doesn't implement the "export" feature, then define blah
blah...

While I'm at it, are there any othere things in the C++ Standard that
aren't done properly by a lot of compilers?

-Tomás
Feb 18 '06 #1
4 1541
Tomás wrote:
[...]
I'm going to put a "readme" file with it saying:

If your compiler doesn't implement the "export" feature, then define blah
blah...


Try 'if your compiler implements the "export" feature,
then _undefine_ blah blah'. Compilers that support 'export'
are in the minority :)

- J.
Feb 18 '06 #2

Tomás wrote:
I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.
<snip discussion of the technique in FAQ 35.14>
Do many of you here use this? I'm thinking of starting to use it in my
code. I'm going to put a "readme" file with it saying:

If your compiler doesn't implement the "export" feature, then define blah
blah...
Having never used the technique I can't usefully comment on it, however
....
While I'm at it, are there any othere things in the C++ Standard that
aren't done properly by a lot of compilers?


.... if you are trying to write portable and conformant code, one issue
you may run into is the <cxxx> vs <xxx.h> C library headers. Quite a
lot of compilers (MSVC++ 8, Comeau online last time I checked, GCC
3.4.2 in Dev C++) implement the <cxxx> headers incorrectly in that C
library names are placed in the global namespace as well as namespace
std. So if you forget to prepend printf with std:: your code will be
incorrect but the compiler won't complain.

Gavin Deane

Feb 18 '06 #3
Tomás wrote:

I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.

I like the "export" feature, whereby I can put template functions in
source files (where I feel they belong -- unless I intend them to be
inline, of course).

I realise, however, that the majority of compilers are defective in that
they do not implement the "export" feature.
One could argue that it might be the standard that is defective. If the
majority of compilers don't implement that feature even 7 years after the
standard was released, this indicates that this feature is problematic.
I see that the FAQ offers an alternative:

//header.hpp
template<class T>
T Get();

#ifdef UNSUPPORTED_EXPORT_KEYWORD
#include "header.cpp"
#endif
//header.cpp
#ifdef UNSUPPORTED_EXPORT_KEYWORD
#define export
#endif

export template<class T>
T Get()
{
return 0;
}
Do many of you here use this?
I don't see any real advantage in this. Usually, you do such things if
several compilers must be treated differently, but the non-export version
works on all compilers, so IMHO, this just adds unnecessary clutter.
While I'm at it, are there any othere things in the C++ Standard that
aren't done properly by a lot of compilers?


Maybe two-phase lookup.
Feb 18 '06 #4
In article <kG******************@news.indigo.ie>,
"Tomás" <NU**@NULL.NULL> wrote:
I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.
Do it like they do it at "boost.org". They have several defines to get
around compiler problems already in their library. Use them and maybe
one day, you can submit your stuff for inclusion in their library.
I see that the FAQ offers an alternative:

//header.hpp
template<class T>
T Get();

#ifdef UNSUPPORTED_EXPORT_KEYWORD
#include "header.cpp"
#endif
//header.cpp
#ifdef UNSUPPORTED_EXPORT_KEYWORD
#define export
#endif

export template<class T>
T Get()
{
return 0;
}

boost.org doesn't do the above...

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 18 '06 #5

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

Similar topics

3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
1
by: Alex | last post by:
Hi all, I've seen this noted in many posts, but nothing I've checked out gives me any clue on how to do this. Basically as my topic says, I have a DTS and I simply need to export some data...
1
by: Jacky11 | last post by:
I have a column name the Data type is MEMO The input is more than thousands of characters. When exporting, not all the information is exported. Who can I correct this problem? Thanks
2
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
3
by: gowens | last post by:
I have an ASP.Net multi-part tabbed page. One of the tab pages contains several controls (including a DataList). The DataList contains, virtually-rendered, Database images and some text fields....
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
2
by: Larry L | last post by:
Hi guys, been a while since I've been on the group, glad to see some regulars are still around! I've got an app that outputs a scale model plan to a printer, printing to a lettersize or a4...
0
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
hi, I trying to export data display on a gridview that supports any language (like chinese, japanese, thai, french) shown here is chinese only. There is no problem exporting english language...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.