public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Win32 Defines & C++
@ 1999-03-24  9:45 Nirmal Prasad
  1999-03-31 19:45 ` Nirmal Prasad
  0 siblings, 1 reply; 8+ messages in thread
From: Nirmal Prasad @ 1999-03-24  9:45 UTC (permalink / raw)
  To: John F. Kolen; +Cc: cygwin

John F.Kolen Wrote :
>What about
>
>#include <winstuff>
>
>#undef GetNextWindow
>...
>  void GetNextWindow(...
>
>#define GetNextWindow(h,c)    GetWindow(h,c)        /* somewhere in some
>
and Larry Hall Wrote :
>Why don't you just check to see if GetNextWindow() is defined and undefine
>it if it is in your code? This should work and requires only minor code
>changes...

hi,

first and formemost "thanks for the suggestion" but the problem with this
method is that if u consider the implementation of the method in the class
(this is usually the case for wrapper classes) i.e
void test::GetNextWindow(uint c)
{
    //.. some checks...
    ::GetNextWindow(internal_handle,c);
    //... some post processing for error handling
}

so now we run into a problem that the original GetNextWindow(..) has now
undefined. Well i found that the "inline" solution would work better than
#undef unless i am missing something.

Regards

Nirmal Prasad R.


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Win32 Defines & C++
  1999-03-24  9:45 Win32 Defines & C++ Nirmal Prasad
@ 1999-03-31 19:45 ` Nirmal Prasad
  0 siblings, 0 replies; 8+ messages in thread
From: Nirmal Prasad @ 1999-03-31 19:45 UTC (permalink / raw)
  To: John F. Kolen; +Cc: cygwin

John F.Kolen Wrote :
>What about
>
>#include <winstuff>
>
>#undef GetNextWindow
>...
>  void GetNextWindow(...
>
>#define GetNextWindow(h,c)    GetWindow(h,c)        /* somewhere in some
>
and Larry Hall Wrote :
>Why don't you just check to see if GetNextWindow() is defined and undefine
>it if it is in your code? This should work and requires only minor code
>changes...

hi,

first and formemost "thanks for the suggestion" but the problem with this
method is that if u consider the implementation of the method in the class
(this is usually the case for wrapper classes) i.e
void test::GetNextWindow(uint c)
{
    //.. some checks...
    ::GetNextWindow(internal_handle,c);
    //... some post processing for error handling
}

so now we run into a problem that the original GetNextWindow(..) has now
undefined. Well i found that the "inline" solution would work better than
#undef unless i am missing something.

Regards

Nirmal Prasad R.


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Win32 Defines & C++
  1999-03-24  9:14   ` Mumit Khan
@ 1999-03-31 19:45     ` Mumit Khan
  0 siblings, 0 replies; 8+ messages in thread
From: Mumit Khan @ 1999-03-31 19:45 UTC (permalink / raw)
  To: Nirmal Prasad; +Cc: cygwin

On Wed, 24 Mar 1999, Nirmal Prasad wrote:

> This is not a cygwin related query,bug or feature request but if someone can
> help it will be great b'cos i am getting this problem in some code that i
> have while compiling under cygwin.

Neither is this a GCC problem, since you'll get the same result with MSVC
or any other C++ compiler!

> The problem i am facing is that i have some c++ class that has a member
> function which is the same as a win32 define (e.g. GetNextWindow). The
> problem is that the pre-processor substitues this and the compiler complains
> that there is something wrong. One of the solutions i thought of getting
> around this is to make the #define'd macro to an inline function and the
> code would then compile but this would be tedious if its a lot of macros . I
> was wondering if there is any other elegant solution such that i dont have
> to change any code.????

The problem of these macro definitions in Win32 API headers causes lots
of problems even in standard-conformant code; the only (obvious) suggestion 
I can give is not to name member functions with the same name as a win32 
API function (or just rename it when you find one that clashes).

The API headers were designed by folks who think C is the only language,
and even botches that badly.

Years ago, I remember putting together a set of platform specific
"undef.h" files that I would include after the system includes to avoid
this mess, but that really isn't the right solution. However, since you
want to avoid code changes, this may be a solution for you. 

Regards,
Mumit



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Win32 Defines & C++
  1999-03-24  7:24 Nirmal Prasad
       [not found] ` < 001701be7609$ef953970$0f0a0181@devel014 >
@ 1999-03-31 19:45 ` Nirmal Prasad
  1 sibling, 0 replies; 8+ messages in thread
From: Nirmal Prasad @ 1999-03-31 19:45 UTC (permalink / raw)
  To: cygwin

hi there,

This is not a cygwin related query,bug or feature request but if someone can
help it will be great b'cos i am getting this problem in some code that i
have while compiling under cygwin.

The problem i am facing is that i have some c++ class that has a member
function which is the same as a win32 define (e.g. GetNextWindow). The
problem is that the pre-processor substitues this and the compiler complains
that there is something wrong. One of the solutions i thought of getting
around this is to make the #define'd macro to an inline function and the
code would then compile but this would be tedious if its a lot of macros . I
was wondering if there is any other elegant solution such that i dont have
to change any code.????

Thanks in advance

Regards

Nirmal Prasad R.

e.g.
#define GetNextWindow(h,c)    GetWindow(h,c)        /* somewhere in some
win32 header */

//.. This is in my file
class test
{
    public:
            ... some members
           void GetNextWindow(uint c);                //<- get an error here
as "GetNextWindow" called with 1 argument only
};


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Win32 Defines & C++
  1999-03-24  7:22 Nirmal Prasad
@ 1999-03-31 19:45 ` Nirmal Prasad
  0 siblings, 0 replies; 8+ messages in thread
From: Nirmal Prasad @ 1999-03-31 19:45 UTC (permalink / raw)
  To: cygwin

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Win32 Defines & C++
       [not found] ` < 001701be7609$ef953970$0f0a0181@devel014 >
@ 1999-03-24  9:14   ` Mumit Khan
  1999-03-31 19:45     ` Mumit Khan
  0 siblings, 1 reply; 8+ messages in thread
From: Mumit Khan @ 1999-03-24  9:14 UTC (permalink / raw)
  To: Nirmal Prasad; +Cc: cygwin

On Wed, 24 Mar 1999, Nirmal Prasad wrote:

> This is not a cygwin related query,bug or feature request but if someone can
> help it will be great b'cos i am getting this problem in some code that i
> have while compiling under cygwin.

Neither is this a GCC problem, since you'll get the same result with MSVC
or any other C++ compiler!

> The problem i am facing is that i have some c++ class that has a member
> function which is the same as a win32 define (e.g. GetNextWindow). The
> problem is that the pre-processor substitues this and the compiler complains
> that there is something wrong. One of the solutions i thought of getting
> around this is to make the #define'd macro to an inline function and the
> code would then compile but this would be tedious if its a lot of macros . I
> was wondering if there is any other elegant solution such that i dont have
> to change any code.????

The problem of these macro definitions in Win32 API headers causes lots
of problems even in standard-conformant code; the only (obvious) suggestion 
I can give is not to name member functions with the same name as a win32 
API function (or just rename it when you find one that clashes).

The API headers were designed by folks who think C is the only language,
and even botches that badly.

Years ago, I remember putting together a set of platform specific
"undef.h" files that I would include after the system includes to avoid
this mess, but that really isn't the right solution. However, since you
want to avoid code changes, this may be a solution for you. 

Regards,
Mumit



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Win32 Defines & C++
@ 1999-03-24  7:24 Nirmal Prasad
       [not found] ` < 001701be7609$ef953970$0f0a0181@devel014 >
  1999-03-31 19:45 ` Nirmal Prasad
  0 siblings, 2 replies; 8+ messages in thread
From: Nirmal Prasad @ 1999-03-24  7:24 UTC (permalink / raw)
  To: cygwin

hi there,

This is not a cygwin related query,bug or feature request but if someone can
help it will be great b'cos i am getting this problem in some code that i
have while compiling under cygwin.

The problem i am facing is that i have some c++ class that has a member
function which is the same as a win32 define (e.g. GetNextWindow). The
problem is that the pre-processor substitues this and the compiler complains
that there is something wrong. One of the solutions i thought of getting
around this is to make the #define'd macro to an inline function and the
code would then compile but this would be tedious if its a lot of macros . I
was wondering if there is any other elegant solution such that i dont have
to change any code.????

Thanks in advance

Regards

Nirmal Prasad R.

e.g.
#define GetNextWindow(h,c)    GetWindow(h,c)        /* somewhere in some
win32 header */

//.. This is in my file
class test
{
    public:
            ... some members
           void GetNextWindow(uint c);                //<- get an error here
as "GetNextWindow" called with 1 argument only
};


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Win32 Defines & C++
@ 1999-03-24  7:22 Nirmal Prasad
  1999-03-31 19:45 ` Nirmal Prasad
  0 siblings, 1 reply; 8+ messages in thread
From: Nirmal Prasad @ 1999-03-24  7:22 UTC (permalink / raw)
  To: cygwin

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1999-03-31 19:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-24  9:45 Win32 Defines & C++ Nirmal Prasad
1999-03-31 19:45 ` Nirmal Prasad
  -- strict thread matches above, loose matches on Subject: below --
1999-03-24  7:24 Nirmal Prasad
     [not found] ` < 001701be7609$ef953970$0f0a0181@devel014 >
1999-03-24  9:14   ` Mumit Khan
1999-03-31 19:45     ` Mumit Khan
1999-03-31 19:45 ` Nirmal Prasad
1999-03-24  7:22 Nirmal Prasad
1999-03-31 19:45 ` Nirmal Prasad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).