C++ export keyword
Nathan Sidwell
nathan@codesourcery.com
Fri Apr 11 09:45:00 GMT 2003
Ryan McDougall wrote:
> Hello,
> I noticed that the export keyword has been un implemented for a long
> time. This is affecting my work since I cant use g++ to develop at home.
> Solaris CC compiler doesnt support export, but it does allow my code to
> compile ( somehow :).
>
> Is there any timeframe or schedule for when this bug will be addressed?
> I would hate to have to install a non GCC compiler just to be able to
> work at home.
I do not believe the sun compiler does not support export, if it is doing
separate compilation of templates, it is using a non-export mechanism.
You can write source that works with or with out export. The basic idea is
that you do something like;
/// file.h
#if !FILE_H_INCLUDED
#define FILE_H_INCLUDED 1
#if !HAVE_EXPORT // this bit should be in a config.h file
#define export
#endif
export template <typename T> void Foo (T);
#if !HAVE_EXPORT && !FILE_CC_INCLUDED
#define FILE_CC_INCLUDED 1
#include "file.cc"
#endif
#endif
// file.cc
#if !FILE_CC_INCLUDED
#define FILE_CC_INCLUDED 1
#include "file.h"
#endif
template <typename T> void Foo (T arg)
{
// do the foo thing
}
You may need an auxilary file or something, or else you need to be
careful what you put in file.cc. This organization also has the advantage
that users of file.h do not have to look at the implementation when wading
through the header file to learn the interface.
Alternatively, -frepo might be what you're looking for.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
More information about the Gcc-bugs
mailing list