Joemccay | 1 Sep 2003 03:51
Picon
Favicon

Templates and MingW

   I am used to using VC++ 6.0 & templates.  I have found out that I have to explicitly instantiate templates (after reading Tom Swan's GNU C++ book).  Are there some examples/tutorials that show exmaples of all the possibility for link with templates under mingw?  Explicit instantiation is nice when you know know everything you want to use the template with, but that may not be the case.  I would prefer to have the compiler automatically instantiate the instances of templates. 
   I understand that explicit instantiation can make for cleaner code, but it seems to defeat the purpose of templates.  How is the undefined reference problem gotten around in the STL for user defined templates?
Thank you in advance.
Joe M.
Greg Chicares | 1 Sep 2003 05:53
Picon

Re: Templates and MingW

Joemccay@... wrote:
> 
>    I am used to using VC++ 6.0 & templates.  I have found out that I have to explicitly instantiate templates
(after reading Tom
> Swan's GNU C++ book).

Is it an old book? It is not generally necessary to
instantiate templates explicitly with g++.

> Are there some examples/tutorials that show exmaples of all the possibility for link with templates under
> mingw?

See this URL:
  http://gcc.gnu.org/onlinedocs/gcc/Template-Instantiation.html
but bear in mind that mingw lacks 'collect2', so
'-frepo' won't work.

> Explicit instantiation is nice when you know know everything you want to use the template with, but that
may not be the
> case.  I would prefer to have the compiler automatically instantiate the instances of templates.

g++ does perform automatic instantiation. Its
shortcoming is that it does too much instantiation
automatically. But don't worry about that unless
measurements prove it's a problem for you.

>    I understand that explicit instantiation can make for cleaner code,

It makes the source more complicated and harder to
maintain. But it can make many object files smaller.

> but it seems to defeat the purpose of templates.

Agreed.

> How is the
> undefined reference problem gotten around in the STL for user defined templates?

I'm not sure what you mean--care to elaborate?

BTW, it's easier to read and reply to your email if
you post flat text with shorter lines. I get these
spam headers added to your original message--I
guess sourceforge adds them:

> X-Spam-Report: 2.5/5.0
>         The original message has been attached along with this report, so
>         you can recognize or block similar mail in future.
[...]
>         NO_REAL_NAME       (0.8 points)  From: does not include a real name
>         HTML_MESSAGE       (0.1 points)  BODY: HTML included in message
>         HTML_10_20         (1.4 points)  BODY: Message is 10% to 20% HTML
>         MIME_LONG_LINE_QP  (0.2 points)  RAW: Quoted-printable line longer than 76 characters

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Jonathan Wilson | 1 Sep 2003 09:25
Picon

I am going to attempt to add Thread Local Storage to MingW

I have studied how TLS works in win32 and it doesnt seem that hard 
(especially since GCC already supports TLS for some platforms)

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Earnie Boyd | 1 Sep 2003 11:59
Picon

[mini-FAQ/reminder]

Introduction
============
You receive this message because you are subscribed to the MinGW
mailing list. This is a reminder/mini-FAQ sent once a month. If 
you want to unsubscribe from the mingw-users mail list you can do 
so at http://lists.sourceforge.net/mailman/listinfo/mingw-users.  
Have your password handy (if you can't find it, you'll be offered 
an option to have it mailed to you).

What is MinGW?
==============
MinGW stands for "Minimalist GNU for Windows" and is a development
package (as well as target) which allows you to compile software 
for "native" Windows 32-bit platforms.  Please visit our website 
http://www.mingw.org for more information.

Who authored MinGW? How is it maintained? What is its licensing?
================================================================
MinGW was created by Colin Peters and was placed by him into the 
public domain.  There is no centralized force behind MinGW - it is 
maintained by volunteers and its development directed by the user 
community.  MinGW uses free GNU C/C++ compiler, its core libraries
and headers (Win32 import libraries and header definitions) are in 
public domain and it uses the vendor-supplied runtime library, so
in short, you can use it to develop royalty-free software, either
open- or close-sourced.  For more comprehensive licensing terms,
please visit http://www.mingw.org/licensing.shtml

Can MinGW be used to compile GNU or OpenSource software?
========================================================
The MinGW runtime library adheres to the ANSI C standard and
offers very little POSIX compatibility.  While some packages may
compile "out of the box", many will require porting.  Most GNU
software uses the GNU "configure; make; make install" procedure,
which requires a borne compliant shell, and a handful of UNIX like
utilities.  Some of this functionality is provided by MSYS, 
please see "What is MSYS and why should I use it?" below for
more information.

Can MinGW be used to compile MSVC projects?
===========================================
Because MinGW was specifically created to allow "native" runtimes to
be compiled with GCC, most MSVC projects will compile without change.
However, with many projects there maybe a requirement to modify the 
build procedure.  Tools for automating MSVC project conversion are
available in the MinGW-utils package. 

What is MSYS and why should I use it?
=====================================
MSYS stands for Minimal SYStem and is a shell environment created
for use with the MinGW package.  MSYS provides the ability to 
execute configure scripts.  It also includes some *nix utilities
such as the vi editor.

For further details on MSYS please visit:

http://www.mingw.org/msys.shtml

Support
=======
The main source of user information can be found at MinGW's website
at http://www.mingw.org/.  There, you can find general information, 
download and installation instructions, links to ported software, 
FAQ, history and news, etc.  

The MinGW mailing list is a place to ask questions, discuss MinGW
related issues and announce availability of software.  Before 
posting questions, please make sure that it is not covered in the 
comprehensive FAQ (http://www.mingw.org/mingwfaq.shtml) or already 
discussed in the mailing list archives which are accessible from 
the mailing list homepage or the seach facility provided on the 
leftside of the MinGW home page.

Reporting bugs and contributing
===============================
MinGW's existence and development is impossible without community
attention and contribution.  

For details on reporting bugs please refer to:

http://www.mingw.org/bugs.shtml

Submit patches for MinGW runtime/tools, corrections and additions 
for the web pages via:

http://sourceforge.net/patch/?func=addpatch&group_id=2435 .

MinGW maintainers,
http://sourceforge.net/projects/mingw/

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Jonathan Wilson | 1 Sep 2003 13:26
Picon

how do I compile GCC?

I have gcc-g++-3.3.1-20030804-1-src.tar.gz, 
gcc-core-3.3.1-20030804-1-src.tar.gz & 
binutils-2.14.90-20030807-1-src.tar.gz from the MingW download page.

What do I need and what do I do/run in order to get a working MingW GCC 
build going?

Also, how would I go about contributing changes to MingW binutils and MingW 
GCC? (I wanna add Thread Local Storage support)

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Picon

strange linking dll PASCAL/WINAPI functions

Hello mingw-users,

My MinGW is from MinGW-2.0.0-3.exe

$ gcc --version
gcc.exe (GCC) 3.2 (mingw special 20020817-1)

I tried to write a simple ping program.
I used functions IcmpCreateFile(),IcmpCloseHandle() and IcmpSendEcho() from icmp.dll,
and inet_addr() from wsock32.dll.
I know for sure that all 4 are the PASCAL functions (mostly from
the lcc header files).

The ICMP functions are not declared in gcc headers, so I declared them
in my source as follows:

   extern HANDLE PASCAL IcmpCreateFile(void);
   extern BOOL WINAPI IcmpCloseHandle(HANDLE);
   extern DWORD PASCAL IcmpSendEcho(<arg list>);

The inet_addr() is declared in winsock2.h as

   unsigned long PASCAL inet_addr(const char*);

So far so good.
In my first attempt I built import libraries with the following
.def's:

(icmp.def)
EXPORT
IcmpCreateFile <at> 0
IcmpCloseHandle <at> 4
IcmpSendEcho <at> 32

(wsock32.def)
EXPORT
inet_addr <at> 4

All went ok: libs built, source compiled and exe built.
But when I run the mping.exe the dialog popped, saying that function
IcmpCreateFile <at> 0 wasn't found.

Then I took another way.
I removed the PASCAL word from function declarations in my source
and ***in the gcc's winsock2.h***. Changed .def's appropriately.
EXPORT
IcmpCreateFile
IcmpCloseHandle
IcmpSendEcho

EXPORT
inet_addr

Hmm... IT WORKS.

What's happening, please? Am I missing something?

--

-- 
Best regards,
 Сергей                          mailto:serge@...

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Luke Dunstan | 1 Sep 2003 16:34
Picon
Favicon

Re: strange linking dll PASCAL/WINAPI functions


With the original stdcall declarations you need to use the "--kill-at" flag
to dlltool when building the import libraries (just removing the PASCAL will
make programs crash). By default, the name stored in the import table and
the symbol in the import library are the same apart from underscores (e.g.
"IcmpCreateFile <at> 0") but when you add this flag it means that the name in the
.exe import table will be "IcmpCreateFile", while the symbol name remains
the same. This is necessary because the import library symbol has to match
what the compiler outputs and the import table must match the export table
of the DLL. If you look in the w32api source you'll see that the "-k"
(--kill-at) flag is used there too. However, inet_addr is already present in
the current version of libwsock32.a so you shouldn't need to add it (just
use -lwsock32 when linking).

Luke

----- Original Message ----- 
From: "Сергей Самоходкин" <serge@...>
To: <mingw-users@...>
Sent: Monday, September 01, 2003 9:59 PM
Subject: [Mingw-users] strange linking dll PASCAL/WINAPI functions

> Hello mingw-users,
>
> My MinGW is from MinGW-2.0.0-3.exe
>
> $ gcc --version
> gcc.exe (GCC) 3.2 (mingw special 20020817-1)
>
> I tried to write a simple ping program.
> I used functions IcmpCreateFile(),IcmpCloseHandle() and IcmpSendEcho()
from icmp.dll,
> and inet_addr() from wsock32.dll.
> I know for sure that all 4 are the PASCAL functions (mostly from
> the lcc header files).
>
> The ICMP functions are not declared in gcc headers, so I declared them
> in my source as follows:
>
>    extern HANDLE PASCAL IcmpCreateFile(void);
>    extern BOOL WINAPI IcmpCloseHandle(HANDLE);
>    extern DWORD PASCAL IcmpSendEcho(<arg list>);
>
> The inet_addr() is declared in winsock2.h as
>
>    unsigned long PASCAL inet_addr(const char*);
>
> So far so good.
> In my first attempt I built import libraries with the following
> .def's:
>
> (icmp.def)
> EXPORT
> IcmpCreateFile <at> 0
> IcmpCloseHandle <at> 4
> IcmpSendEcho <at> 32
>
> (wsock32.def)
> EXPORT
> inet_addr <at> 4
>
> All went ok: libs built, source compiled and exe built.
> But when I run the mping.exe the dialog popped, saying that function
> IcmpCreateFile <at> 0 wasn't found.
>
> Then I took another way.
> I removed the PASCAL word from function declarations in my source
> and ***in the gcc's winsock2.h***. Changed .def's appropriately.
> EXPORT
> IcmpCreateFile
> IcmpCloseHandle
> IcmpSendEcho
>
> EXPORT
> inet_addr
>
> Hmm... IT WORKS.
>
> What's happening, please? Am I missing something?
>
> -- 
> Best regards,
>  Сергей                          mailto:serge@...

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Oscar Fuentes | 1 Sep 2003 18:15
Picon

Re: how do I compile GCC?

Jonathan Wilson <jonwil@...> writes:

> I have gcc-g++-3.3.1-20030804-1-src.tar.gz,
> gcc-core-3.3.1-20030804-1-src.tar.gz &
> binutils-2.14.90-20030807-1-src.tar.gz from the MingW download page.
>
> What do I need and what do I do/run in order to get a working MingW
> GCC build going?

The package gcc-3.3.1-20030804-1-src.diff.gz, which contains the MinGW
specific patches, possibly contains an script for building MinGW. In
essence, on a POSIX environment, you follow the build instructions
included with GCC, that is, 'make bootstrap [options]'. The above
mentioned script does that adding the appropriate options. IIRC, Danny
Smith uses Cygwin, but it should work on MSYS too.

Don't forget to apply the MinGW specific patches before building the
retail GNU packages, unless you have a reason for not doing so.

> Also, how would I go about contributing changes to MingW binutils
> and MingW GCC? (I wanna add Thread Local Storage support)

There is a patch submission facility on the MinGW SourceForge page:

http://sourceforge.net/tracker/?group_id=2435&atid=302435

Have fun.

--

-- 
Oscar

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Thomas Tutone | 1 Sep 2003 19:55
Picon
Favicon

Increasing stack size

Is there a straight-forward way to increase MinGW's
run-time stack size?  I have some code that is very
heavily recursive, and under certain conditions when
the .exe is running it overflows the stack, which
terminates the program.  djgpp has a system variable
one can set to increase the stack size.  Does a
similar facility exist for MinGW?  I've checked the
archives, but couldn't find anything on point.

Thanks in advance.

Best regards,

Tom

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MinGW-users mailing list
MinGW-users@...

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

Joemccay | 1 Sep 2003 20:52
Picon
Favicon

Re: Templates and Mingw

   I should note that I do development with Dev-C++, but I also have rc4 loaded & msys to compile the wxWindows library.  I also split the template into .h & .cpp.  When I first tried to compile it, I got undefined reference errors from the linker pertaining to the templates.  I tried compiling it with rc4 once and got the same errors.

   I have got the instantiation code within defines so I easily turn it on and off with a simple link.

   Would I get these errors if I put everything in on .h file instead of .cpp & .h?  Are their any special flags I should be using?  I really don't like the idea of using explicit instantiation, but it was the only way I could get it to compile.

    As for the book, it is copywritten in 2000, so it is a bit old.  As for the header stuff, I think that might be AOL crap, but I get this email account for free which is good considering my small income level at the moment.  I am currently writing this email in Arial 10pt.  If there is a better font, let me know.  Other than that, I can try sending it from my yahoo account next time.

Gmane