From: Timothy Madden on 29 Jan 2010 14:56 Hello I have Visual Studio 2008 Service Pack at work and I would like to write my template code in a .cpp file, and only the template declarations in the .h or .hpp file, as if export would be supported and as if I could export my templates. However without export support for such separation to actually work the header file will include the .cpp file with a conditional compilation directive like #ifndef USE_EXPORT # include "File.cpp" #endif and also, for things to work, the .cpp file should include only template or inline functions definitions. Please don't bother too much with the ugly idea that I include a .cpp file; the file is really meant to define templates only and be included if necessary. The advantage is that with export support I would then just define USE_EXPORT for my project and all templates, already separated in .cpp files, will no longer be bodily included and will get exported. If you have read some things about templates a little you will find that this is a quite known approach and that it works very nice. However for that I would like to declare my templates with the export keyword, and have the compiler ignore it (as other compilers do, to support this separation model). I see my cl already outputs a warning that export 'is not yet supported, but reserved', but immediately after the warning I also get an error, which is a problem. Can I somehow get the compiler to ignore export with some options or pragmas ? I know I can use a define instead, that will expand to export only when possible, but I would really like to keep my code clear, with the export keyword as is, and rather set some project options to avoid my problem ... Thank you, Timothy Madden
From: Igor Tandetnik on 29 Jan 2010 16:14 Timothy Madden <terminatorul(a)gmail.com> wrote: > However for that I would like to declare my templates with the export > keyword, and have the compiler ignore it (as other compilers do, to > support this separation model). > > I see my cl already outputs a warning that export 'is not yet > supported, but reserved', but immediately after the warning I also > get an error, which is a problem. > > Can I somehow get the compiler to ignore export with some options or > pragmas ? #define export This is, technically, illegal - you are not supposed to #define macros whose names match language keywords. But it would work, in a pinch. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Timothy Madden on 2 Feb 2010 06:47 Igor Tandetnik wrote: > Timothy Madden <terminatorul(a)gmail.com> wrote: >> However for that I would like to declare my templates with the export >> keyword, and have the compiler ignore it (as other compilers do, to >> support this separation model). >> >> I see my cl already outputs a warning that export 'is not yet >> supported, but reserved', but immediately after the warning I also >> get an error, which is a problem. >> >> Can I somehow get the compiler to ignore export with some options or >> pragmas ? > > #define export > > This is, technically, illegal - you are not supposed to #define macros whose names match language keywords. But it would work, in a pinch. In the end that is what I did. I was wondering if the compiler has or is going to have better support for this, though ... Thank you, Timothy Madden
|
Pages: 1 Prev: package installation for explorer bar vc++ Next: enum operator overloading VC9 compiler bug? |