🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.migration
Article #132

Re: Still not working.

#132
From: Ed Mulroy [TeamB]
Date: Mon, 07 Jul 2008 01:31
68 lines
3645 bytes
The code in a templated function actually specifies the algorithm rather 
than the code.  Only when it is called is the type of the template argument 
specified so only at that point does it have the information necessary to 
generate code.

For example: were it called with a double, machine code for floating point 
arithmetic must be generated and if called with an int, code for fixed point 
generated.

In this compilation unit only the function prototype is supplied so the 
compiler must depend upon a call to a function it hopes has been resolved 
with the appropriate type.  The linker must resolve that so it must find a 
public symbol for this function as expanded for the needed type.

In the DLL code that you do not show, insert a call to the function using 
the type that is needed so that a version of the function for that type will 
be available.

The use of 'export', '_export', '__export', 'import', '_import' and 
'__import' was replaced when the current compiler went to 32 bits only.  The 
C++ Language standard now includes 'export' as a C++ keyword with a 
different meaning than that for which you are using it.

The old words are in the compiler for those who cannot avoid legacy code and 
are not intended for code from the last 10 years or code meeting the C++ 
Language Standard of the last 10 or so years.   Do what Mr Lebeau has said 
and use __declspec(dllexport) for _export and __declspec(dllimport) for 
_import.

.  Ed

> Gene wrote in message
> news:48716d01$1@newsgroups.borland.com...
>
> It doesn't seem to work. The only purpose I have the inline function 
> exported is to test if a function that takes a template class auguement 
> works. I have a couple of that kind of functons in my old BCB6 project, 
> they are ok when I use my old way in BCB6. When I upgrade to BCB2007, all 
> exported functions are ok except those functions that takes tamplate class 
> auguements.
>
> Any further idea, Remy? Thanks a lot!
>
>
> "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>>
>>"Gene" <shenjige@yahoo.ca> wrote in message
>>news:486fa525$1@newsgroups.borland.com...
>>
>>> #ifdef __BUILDING_DLL
>>>  #define __EXPORT_TYPE __export
>>> #else
>>>  #define __EXPORT_TYPE __import
>>> #endif
>>
>>Use ___declspec() instead:
>>
>>    #ifdef __BUILDING_DLL
>>        #define __EXPORT_TYPE __declspec(dllexport)
>>    #else
>>        #define __EXPORT_TYPE __declspec(dllimport)
>>    #endif
>>
>>> template <class T>
>>> void __EXPORT_TYPE ClearContainer(T& x) { T y; y.swap(x); };
>>
>>Why are you trying to export an inlined template function?  That is not
>>necessary.
Technical Details
Message-ID: <487171ee$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <486fa525$1@newsgroups.borland.com> <48706b97@newsgroups.borland.com> <48716d01$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 110f51,ff6960108b83e27b
X-Google-Attributes: gid110f51,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.migration
References: <486fa525$1@newsgroups.borland.com> <48706b97@newsgroups.borland.com> <48716d01$1@newsgroups.borland.com>
Subject: Re: Still not working.
Date: Sun, 6 Jul 2008 21:31:29 -0400
Lines: 70
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 69.142.0.27
Message-ID: <487171ee$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1215394286 69.142.0.27 (6 Jul 2008 18:31:26 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail