🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42553

Re: gcc for Windows 95/NT: compiling C++?

#42553
From: Kai Ruottu
Date: Fri, 24 Nov 1995 00:00
148 lines
6069 bytes
In article <491q3h$bnj@aragorn.unibe.ch>, ghisler@iap.unibe.ch (Christian Ghisler) says:
>
>Hi!
>
>karuottu@freenet.hut.fi (Kai Ruottu) wrote:
>
>> The Cygnus headers are not C++ aware yet in the release 8.  The Release 9
>>seems to just came out, so check that first....
>
>Thanks for letting me know! Which is the primary site for GCC for NT?
>ftp://src.doc.ic.ac.uk/gnu/cygnus/sac still only has Beta 8.
>

It's ftp.cygnus.com /pub/sac/win32

>In the meantime I translated all the OLE2 C++ stuff I need to use to
>plain C and it finally works, even as a DLL. Some of the DLL tables
>look a bit strange (if viewed with Win95 quick view), but the DLL is
>detected by my program. I also wrote a little program and I had to
>patch one byte in the header from value 3 to 2 to get a true Windows
>GUI application. Otherwise a console is opened first and then the main
>window of the program opens. Perhaps a compiler switch to choose
>GUI/Console apps would be appropriate? Is there any documentation for
>GCC/NT compiler switches? I now use the DJGPP docs.
>

 I think there are no documents yet about GNU-Win32 specific switches...
Looking the gcc sources and grep'ing "_WIN32" there could help...

>When I tried to use the OLE2 functions which are essentially a table
>of function pointers I had the problem that the called function
>removed the function arguments from the stack and the calling function
>also removed them, which of course gave a bad stack pointer. I tried
>different prefixes like WINAPI with no success. I finally added a 
>asm("subl 12,esp"); 
>command after each function to adjust the stack, and it finally
>worked. Where can I find any documentation on the GNU C++ language?

 There is an alternative for the Cygnus-compiler: the emx-system from
Eberhard Mattes (look ftp.uni-stuttgart.de /pub/systems/os2/emx-0.9a)
with the RSXNT-package from Rainer Schnitker (ftp.uni-bielefeld.de,
/pub/systems/msdos/misc). This is at level 2.7.0 now. It runs under
DOS, OS/2 (console), Win3.1x (DOS-Box) and perhaps under NT or 95 console
too (I have only Win3.11 with Win32s ... and so cross-compiled the
Cygnus compiler into go32-binaries, so I could test it under Win3.1x...
the compiler works but the generated programs don't under Win32s... The
emx-compiler with NT-libraries & Rainer's NTBIND work very well instead.
There is one header more from Rainer that seems to be needed with macros
for RETURN_WINAPI(PAR), RETURN_CALLBACK(PAR) and RETURN_EXPORT(PAR), when
making 'real' Win32 apps -- not only console apps... This is the header
'WINGNUC.H'... It needs a little trimming when using with the Cygnus
headers -- the emx & RSXNT lacks 32-bit Win headers, so some kind of
marriage is to be done between these packages...

Here is the header anyway:

/*****************************************************************************\
*                                                                             *
* wingnuc.h  -  Macros for GNU C Ver.2.7.1 with the Cygnus Win32 <windows.h>  *
*               Modified from the RSXNT 'wingnuc.h' by Kai Ruottu             *
*               Copyright (c) 1995  Rainer Schnitker.  All rights reserved.   *
*                                                                             *
\*****************************************************************************/

#ifndef _WINGNUC_H
#define _WINGNUC_H

#ifdef __EMX__
#define _WIN32
#endif

#ifdef __GNUC__

#ifndef _WCHAR_T
#define _WCHAR_T
typedef unsigned short wchar_t;
#endif

#ifndef __cdecl
#define __cdecl   __attribute__ ((__cdecl__))
#endif

#ifndef __pascal
#define __pascal
#endif

#ifndef __stdcall
#define __stdcall __attribute__ ((__stdcall__))
#endif

#ifndef _X86_
#define _X86_
#endif

#ifndef _M_IX86
#define _M_IX86     300
#endif

#define _CFRONT_PASS_       /* don't get errors */
#define I386_HOST   1

/* define missing structured exception handlers */

struct _EXCEPTION_RECORD;
struct _CONTEXT;
struct _RTL_CRITICAL_SECTION;
struct tagCREATESTRUCTA;
struct tagCREATESTRUCTW;

/* define WINAPI return command */

#define RETURN_WINAPI(PAR) \
    __asm__ ("1:nop\n\tnop\n\t.stabs \"__RetNT\",36," #PAR ",0,1b-2\n");
#define RETURN_CALLBACK(PAR) \
    __asm__ ("1:nop\n\tnop\n\t.stabs \"__RetNT\",36," #PAR ",0,1b-2\n");
#define RETURN_EXPORT(PAR) \
    __asm__ ("1:nop\n\tnop\n\t.stabs \"__RetNT\",36," #PAR ",0,1b-2\n");

#else  /* not __GNUC__ */

#define RETURN_WINAPI(PAR)
#define RETURN_CALLBACK(PAR)
#define RETURN_EXPORT(PAR)

#endif /* __GNUC__ */

#endif /* _WINGNUC_H */


Hope Rainer will not sue me because of this ...and this is not very
thoroughly thought (the diffs from Rainer's wingnuc.h, but seems to
work for me... This should be included before the Cygnus 'windows.h'
or put near the beginning of the list in it)

>Yes I also noticed that. I have an MSDN II subscription (primarily to
>get Windows NT as a test platform) with all the SDKs so I took the
>missing functions from there, but I suspect that the SDK is
>copyrighted so I cannot simply send you the missing function
>prototypes. If I remember correctly Borland has to pay MS royalties
>for distributing these header files with their C++.
>

The API32WH.HLP seems to be at ftp.funet.fi /pub/win-nt/win32-api, but
alas -- it's corrupted badly (has MS hired hackers to ruin this...). It was
at Cica in Dec. 1993, but not in Apr. 1994 (I have CDROM from this time).
Does somebody know the explanation why it is taken away from Cica?

Regards, Kai
Technical Details
Message-ID: <495l0p$o6v@freenet.hut.fi>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <48f6bv$kto@aragorn.unibe.ch> <karuottu.12.00274233@freenet.hut.fi> <491q3h$bnj@aragorn.unibe.ch>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,aff2148f3816d6f2
X-Google-Attributes: gid11318c,public
From: karuottu@freenet.hut.fi (Kai Ruottu)
Subject: Re: gcc for Windows 95/NT: compiling C++?
Date: 1995/11/24
Message-ID: <495l0p$o6v@freenet.hut.fi>
X-Deja-AN: 120031683
references: <48f6bv$kto@aragorn.unibe.ch> <karuottu.12.00274233@freenet.hut.fi> <491q3h$bnj@aragorn.unibe.ch>
organization: CHOAM
newsgroups: gnu.gcc.help