Thread: [Dev-C++] Export keyword problem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Marcos C. <ca...@un...> - 2002-06-13 19:45:05
Attachments:
carrard.vcf
|
Hi! The book C++ Primer, 3rd edition, Lippmann and Lajoie, speaks on two models of compilation: separation and inclusion. The separation model defines a function in a separate file and it becomes available with the keyword export. I tested this in the Dev and it did not work. The compilation result say that the export keyword is not valid and the linker don=B4t find my function definition. What I can make? The export keyword is not available? Thanks, Marcos |
|
From: Mac R. <re...@no...> - 2002-06-13 21:40:15
|
>The book C++ Primer, 3rd edition, Lippmann and Lajoie, speaks on two
>models of compilation: separation and inclusion. The separation model
>defines a function in a separate file and it becomes available with the
>keyword export. I tested this in the Dev and it did not work. The
I do not have this book available, but in a fair number of years of C and
C++ programming, I have never heard of the "export" keyword, except for DLL
creation in Microsoft compilers. The closest I can think of is the
"extern" keyword, but it is used to import things from other compilation
units, and it is _not_ needed to get access to functions.
Could you give one or more quotes from your book, preferably with small
code examples if possible?
Mac
-
_____________________________ /"\
Mac Reiter \ / ASCII Ribbon Campaign
Nomadics, Inc. X Against HTML Mail
re...@no... / \ (To join the campaign, simply use
this in your signature.)
|
|
From: Jason H. <jas...@nt...> - 2002-06-13 22:25:29
|
Here's a qoute from a reference I have:
"The export keyword can precede a template declaration. It allows other files to use a template
declared in a different file by specifying only its declaration rather than duplicating its entire
definition."
If I remember correctly this feature is very new and not implemented in many compilers yet. It's to
do with the fact that old style binaries/libraries didn't have the ability to represent a templated
function within themselves, they could only represent a template function that had been targetted to
a specific type at compile time, i.e. int, float, MyClass, etc...
Also of interest:
"extern is a data type modifier that tells the compiler about a variable that is defined elsewhere
in a program. This is often used in conjunction with separately compiled files that share the same
global data. In essence, it notifies the compiler about the type of a variable without redefining
it......."
"For C++ only, extern is also used to create a linkage specification......"
Hope this helps,
Jason.
----- Original Message -----
From: "Mac Reiter" <re...@no...>
To: <dev...@li...>
Sent: Thursday, June 13, 2002 10:38 PM
Subject: Re: [Dev-C++] Export keyword problem
>The book C++ Primer, 3rd edition, Lippmann and Lajoie, speaks on two
>models of compilation: separation and inclusion. The separation model
>defines a function in a separate file and it becomes available with the
>keyword export. I tested this in the Dev and it did not work. The
I do not have this book available, but in a fair number of years of C and
C++ programming, I have never heard of the "export" keyword, except for DLL
creation in Microsoft compilers. The closest I can think of is the
"extern" keyword, but it is used to import things from other compilation
units, and it is _not_ needed to get access to functions.
Could you give one or more quotes from your book, preferably with small
code examples if possible?
Mac
-
_____________________________ /"\
Mac Reiter \ / ASCII Ribbon Campaign
Nomadics, Inc. X Against HTML Mail
re...@no... / \ (To join the campaign, simply use
this in your signature.)
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|
|
From: <h.r...@gm...> - 2002-06-15 11:08:41
|
> >The book C++ Primer, 3rd edition, Lippmann and Lajoie, speaks on two
> >models of compilation: separation and inclusion. The separation model
> >defines a function in a separate file and it becomes available with the
> >keyword export. I tested this in the Dev and it did not work. The
>
> I do not have this book available, but in a fair number of years of C and
> C++ programming, I have never heard of the "export" keyword, except for
> DLL
> creation in Microsoft compilers. The closest I can think of is the
> "extern" keyword, but it is used to import things from other compilation
> units, and it is _not_ needed to get access to functions.
>
> Could you give one or more quotes from your book, preferably with small
> code examples if possible?
>
Hi,
here a codesnip from "The C++ Programming Language", B. Stroustrup, 3.
German Edition ,
p. 374:
//out.h
template<class T> void out(const T& t);
//out.c
#include <iostream>
#include "out.h"
export template<class T> void out(const T& t) {std::cerr << t; }
Because the missing (until now) of the export keyword in mingw you have to
write the template definition in the header. Perhaps it will be better in
mingw based on gcc 3.1.
greetings
Horst
--
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net
|
|
From: Ioannis V. <no...@ho...> - 2002-06-15 16:34:52
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of h.r...@gm...
> Sent: Saturday, June 15, 2002 2:09 PM
> To: Dev...@li...
> Subject: Re: [Dev-C++] Export keyword problem
>
>
> Hi,
>
> here a codesnip from "The C++ Programming Language", B. Stroustrup, 3.
> German Edition ,
> p. 374:
>
> //out.h
> template<class T> void out(const T& t);
>
> //out.c
> #include <iostream>
> #include "out.h"
>
> export template<class T> void out(const T& t) {std::cerr << t; }
>
> Because the missing (until now) of the export keyword in
> mingw you have to
> write the template definition in the header. Perhaps it will
> be better in
> mingw based on gcc 3.1.
GCC 3.1:
temp.cpp:2: warning: keyword `export' not implemented, and will be
ignored
Since it recognises it and warns too, things are enough good in terms
of ANSI C++ compliance.
Keep in mind that "export" templates are a tough thing to be
implemented, that's why the usage of the keyword export for template
classes and functions, it is something that indicates special condition
in terms of compilation process. I guess things will get better in some
future release.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|
|
From: Ioannis V. <no...@ho...> - 2002-06-14 02:06:37
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf=20
> Of Marcos Carrard
> Sent: Thursday, June 13, 2002 10:47 PM
> To: dev...@li...
> Subject: [Dev-C++] Export keyword problem
>=20
>=20
> Hi!
>=20
> The book C++ Primer, 3rd edition, Lippmann and Lajoie, speaks on two
> models of compilation: separation and inclusion. The separation model
> defines a function in a separate file and it becomes=20
> available with the
> keyword export. I tested this in the Dev and it did not work. The
> compilation result say that the export keyword is not valid and the
> linker don=B4t find my function definition. What I can make? The =
export
> keyword is not available?
export is for template functions.
For normal functions you provide the definition in a file, e.g.
void something(void)
{
// ...
}
and in the other files that you want to use that function you declare it
before its use (typically at the beginning of the file):
void something(void);
or extern void something(void);
which are both equivallent.
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
* Alternative URL: http://run.to/noicys
|