www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - bool conflicts with windows.h??!!!

reply Laurentiu Pancescu <plaur crosswinds.net> writes:
I have a problem with the following code (booltest.cpp, try
compiling it!):

#include <windows.h>

void test(bool param)
{
  if (param)
    MessageBox(NULL, "Tested", "Bool test", MB_OK);
}

If I use "sc -c booltest.cpp", the compiler expects to find ')'
instead of "param", probably because it doesn't know about
bool.  If I add "-Ab" to the parameter list, the compiling stops
inside <windows.h>, because somewhere in oaidl.h or objidl.h,
Microsoft's headers use the declaration:

_VARIANT_BOOL bool; 
// this gives errors, bool is reserved name with -Ab

I'm using version 8.1d.  Probably the Microsoft headers that DM
comes with are pretty old (bool is reserved word in MSVC now,
so MS headers must have changed).

The only solution I found was "sc -c -Ab -HIstdbool.h" (yep,
that's an ugly one!).  In addition, after all includes, before
using bool in his own source, one must add:

#ifdef __DMC__
#ifdef bool
#undef bool
#endif
#endif

I got into this problem while trying to port V GUI Toolkit
(http://www.objectcentral.com) to DigitalMars, and it contains a
rather large number of files, too large to modify everything like
this!  Perhaps Walter could find a solution on the DigitalMars
compiler's side?


Regards,
  Laurentiu
Sep 09 2001
next sibling parent "Walter" <walter digitalmars.com> writes:
An easy way is just comment out the line in Microsoft's .h file.

Laurentiu Pancescu wrote in message <9nfg21$15df$1 digitaldaemon.com>...
I have a problem with the following code (booltest.cpp, try
compiling it!):

#include <windows.h>

void test(bool param)
{
  if (param)
    MessageBox(NULL, "Tested", "Bool test", MB_OK);
}

If I use "sc -c booltest.cpp", the compiler expects to find ')'
instead of "param", probably because it doesn't know about
bool.  If I add "-Ab" to the parameter list, the compiling stops
inside <windows.h>, because somewhere in oaidl.h or objidl.h,
Microsoft's headers use the declaration:

_VARIANT_BOOL bool;
// this gives errors, bool is reserved name with -Ab

I'm using version 8.1d.  Probably the Microsoft headers that DM
comes with are pretty old (bool is reserved word in MSVC now,
so MS headers must have changed).

The only solution I found was "sc -c -Ab -HIstdbool.h" (yep,
that's an ugly one!).  In addition, after all includes, before
using bool in his own source, one must add:

#ifdef __DMC__
#ifdef bool
#undef bool
#endif
#endif

I got into this problem while trying to port V GUI Toolkit
(http://www.objectcentral.com) to DigitalMars, and it contains a
rather large number of files, too large to modify everything like
this!  Perhaps Walter could find a solution on the DigitalMars
compiler's side?


Regards,
  Laurentiu
Sep 09 2001
prev sibling parent reply Jan Knepper <jan smartsoft.cc> writes:
I fixed that problem with the M$ header files as:

#if defined(__SC__) || defined(__DMC__)
                _VARIANT_BOOL _bool;
#else
                _VARIANT_BOOL bool;
#endif

I also used to have a 'clause' in the __SC__/__DMC__ block with
#if defined(_BOOL_DEFINED) but I removed it.

I guess we will have to patch that in the next release of the
compiler.

Jan



Laurentiu Pancescu wrote:

 I have a problem with the following code (booltest.cpp, try
 compiling it!):

 #include <windows.h>

 void test(bool param)
 {
   if (param)
     MessageBox(NULL, "Tested", "Bool test", MB_OK);
 }

 If I use "sc -c booltest.cpp", the compiler expects to find ')'
 instead of "param", probably because it doesn't know about
 bool.  If I add "-Ab" to the parameter list, the compiling stops
 inside <windows.h>, because somewhere in oaidl.h or objidl.h,
 Microsoft's headers use the declaration:

 _VARIANT_BOOL bool;
 // this gives errors, bool is reserved name with -Ab

 I'm using version 8.1d.  Probably the Microsoft headers that DM
 comes with are pretty old (bool is reserved word in MSVC now,
 so MS headers must have changed).

 The only solution I found was "sc -c -Ab -HIstdbool.h" (yep,
 that's an ugly one!).  In addition, after all includes, before
 using bool in his own source, one must add:

 #ifdef __DMC__
 #ifdef bool
 #undef bool
 #endif
 #endif

 I got into this problem while trying to port V GUI Toolkit
 (http://www.objectcentral.com) to DigitalMars, and it contains a
 rather large number of files, too large to modify everything like
 this!  Perhaps Walter could find a solution on the DigitalMars
 compiler's side?

 Regards,
   Laurentiu
Sep 10 2001
parent reply Laurentiu Pancescu <plaur crosswinds.net> writes:
Cool!  It's really great to see such prompt support from DigitalMars!!

I also did something similar in the 2 header files that used it
(oaidl.h and objidl.h, as I remember), and managed to compile
the V GUI toolkit successfully, at least the core, not yet the
demo applications.

WRT next patch, I saw a lot of messages about people not being
able to compile using DM's IMPLIB import libraries, especially
in the case of system libs.  I also had this problem while I
used the freely downloadable compiler, that only has a small set
of libraries.  (This was before I bought the CD).  However, I
was able to produce *all* the correct import libraries by
myself, including those that were packed with the free compiler.  I
wrote a PERL script that parses and modifies the old MinGW DEF
files, and generates new DEF files, that can be used as direct
input for DM's IMPLIB.  The result is a bunch of import libs
that really work!  :)

Maybe it would be useful to offer the PERL script on DM's FTP
or HTTP (contrib section, perhaps)?  The MinGW DEF files are
still available somewhere on Janjaap FTP, and Perl is widely
spread (I'm using it, so it must be widespread... ;).  Or even the
binary libs?  I think it would be more convenient than mailing
some particular libs to each developer.


Regards,
  Laurentiu

Jan Knepper <jan smartsoft.cc> wrote:

I fixed that problem with the M$ header files as:

#if defined(__SC__) || defined(__DMC__)
                _VARIANT_BOOL _bool;
#else
                _VARIANT_BOOL bool;
#endif

I also used to have a 'clause' in the __SC__/__DMC__ block with
#if defined(_BOOL_DEFINED) but I removed it.

I guess we will have to patch that in the next release of the
compiler.

Jan



Laurentiu Pancescu wrote:

 I have a problem with the following code (booltest.cpp, try
 compiling it!):

 #include <windows.h>

 void test(bool param)
 {
   if (param)
     MessageBox(NULL, "Tested", "Bool test", MB_OK);
 }

 If I use "sc -c booltest.cpp", the compiler expects to find ')'
 instead of "param", probably because it doesn't know about
 bool.  If I add "-Ab" to the parameter list, the compiling stops
 inside <windows.h>, because somewhere in oaidl.h or objidl.h,
 Microsoft's headers use the declaration:

 _VARIANT_BOOL bool;
 // this gives errors, bool is reserved name with -Ab

 I'm using version 8.1d.  Probably the Microsoft headers that DM
 comes with are pretty old (bool is reserved word in MSVC now,
 so MS headers must have changed).

 The only solution I found was "sc -c -Ab -HIstdbool.h" (yep,
 that's an ugly one!).  In addition, after all includes, before
 using bool in his own source, one must add:

 #ifdef __DMC__
 #ifdef bool
 #undef bool
 #endif
 #endif

 I got into this problem while trying to port V GUI Toolkit
 (http://www.objectcentral.com) to DigitalMars, and it contains a
 rather large number of files, too large to modify everything like
 this!  Perhaps Walter could find a solution on the DigitalMars
 compiler's side?

 Regards,
   Laurentiu
Sep 10 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
Laurentiu Pancescu wrote:

 Cool!  It's really great to see such prompt support from DigitalMars!!
We try to be prompt and direct... I guess this time a birthday came in the way... <g>
 WRT next patch, I saw a lot of messages about people not being
 able to compile using DM's IMPLIB import libraries, especially
 in the case of system libs.  I also had this problem while I
 used the freely downloadable compiler, that only has a small set
 of libraries.  (This was before I bought the CD).  However, I
 was able to produce *all* the correct import libraries by
 myself, including those that were packed with the free compiler.  I
 wrote a PERL script that parses and modifies the old MinGW DEF
 files, and generates new DEF files, that can be used as direct
 input for DM's IMPLIB.  The result is a bunch of import libs
 that really work!  :)

 Maybe it would be useful to offer the PERL script on DM's FTP
 or HTTP (contrib section, perhaps)?  The MinGW DEF files are
 still available somewhere on Janjaap FTP, and Perl is widely
 spread (I'm using it, so it must be widespread... ;).  Or even the
 binary libs?  I think it would be more convenient than mailing
 some particular libs to each developer.
I think at sometime we will need to have .DEF files for all the libraries... I send Walter a short (very short) version for USER32.DLL I think. Before the next release there are a couple of things that need to be resolved. One of them is the .DEF files for the libraries and being able to generated the proper import libs from the (system) .DLL's. Jan
Sep 10 2001
parent reply Laurentiu Pancescu <plaur crosswinds.net> writes:
Jan Knepper <jan smartsoft.cc> wrote:

I think at sometime we will need to have .DEF files for all the
libraries...
I send Walter a short (very short) version for USER32.DLL I think. Before
the next release there are a couple of things that need to be resolved.
One of them is the .DEF files for the libraries and being able to
generated the proper import libs from the (system) .DLL's.
I already have that DEF/import stuff working! If you want, I can just send you the PERL script, and the MinGW DEF files, or the already processed DEF files (just to run your IMPLIB on them). For free, of course, I want to help other DM developers, and even to get the next patch sooner... Maybe even the void pointer problem will be adressed, so I'm anxious to see the next patch. Laurentiu
Sep 10 2001
parent Jan Knepper <jan smartsoft.cc> writes:
You can send the ready to use .DEF files to me. I would suggest also sending
them to Walter. He might decided to put them on the site and/or use/include
them on the next CD's...

Jan



Laurentiu Pancescu wrote:

 Jan Knepper <jan smartsoft.cc> wrote:

I think at sometime we will need to have .DEF files for all the
libraries...
I send Walter a short (very short) version for USER32.DLL I think. Before
the next release there are a couple of things that need to be resolved.
One of them is the .DEF files for the libraries and being able to
generated the proper import libs from the (system) .DLL's.
I already have that DEF/import stuff working! If you want, I can just send you the PERL script, and the MinGW DEF files, or the already processed DEF files (just to run your IMPLIB on them). For free, of course, I want to help other DM developers, and even to get the next patch sooner... Maybe even the void pointer problem will be adressed, so I'm anxious to see the next patch. Laurentiu
Sep 10 2001