Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OPOS SO LineDisplay CreateWindow problem

1 view
Skip to first unread message

eskomk

unread,
Jun 4, 2008, 7:02:44 AM6/4/08
to esko.h...@ebsolut.fi
Hi,

How can I solve this problem:
MS VisualStudio C++ thinks that CreateWindow is a macro and tries to
expand it.

It seems that this is a well-known problem, however I have not found
any applicable solution.

-Esko

Maxim S. Shatskih

unread,
Jun 4, 2008, 7:09:32 AM6/4/08
to
Correct, this is a macro defined to CreateWindowA or CreateWindowW

Why is this bad?

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com

"eskomk" <esko.h...@gmail.com> wrote in message
news:0877a2c3-f20b-484f...@e53g2000hsa.googlegroups.com...

eskomk

unread,
Jun 5, 2008, 7:24:30 AM6/5/08
to
On Jun 4, 2:09 pm, "Maxim S. Shatskih" <ma...@storagecraft.com> wrote:
> Correct, this is a macro defined to CreateWindowA or CreateWindowW
>
> Why is this bad?
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> ma...@storagecraft.comhttp://www.storagecraft.com
>
> "eskomk" <esko.huja...@gmail.com> wrote in message

>
> news:0877a2c3-f20b-484f...@e53g2000hsa.googlegroups.com...
>
> > Hi,
>
> > How can I solve this problem:
> > MS VisualStudio C++ thinks that CreateWindow is a macro and tries to
> > expand it.
>
> > It seems that this is a well-known problem, however I have not found
> > any applicable solution.
>
> > -Esko

This clip from
http://www.wincor-nixdorf.com/internet/cae/servlet/contentblob/70232/publicationFile/6402/Opos16readme_download.pdf
explains it better than I can:

CLIP1 -->
Remark 2: For the OPOS line display class, it is necessary
to rename the methods:
DestroyWindow -> xDestroyWindow
CreateWindow -> xCreateWindow
in the wrapper class (*.h and *.cpp file). Also,
the access to these methods in the application
should be done with these names. Otherwise the
C++ - compiler will generate many syntax errors
like
"Create Window: illegal number of arguments in
CreateWindowA"
The reason is a "misunderstanding" between the
Class Wizard and the MSVC system headers. In the
system headers the name CreateWindow and
DestroyWindow are used as macro definitions
and they are mapped to DestroyWindowA and
CreateWindowA in the ANSI version. Microsoft uses
this macro-replacing -mechanism to allow ANSI
and UNICODE compiling. However, if you have C++
classes with a method using a "reserved"
word the compiler will generate errors.
In general: you should not use method names
which are already used in the Window API. This is
not a restriction of the language C++ but of the
MSVC compiler.
CLIP1 <--

It is not only when creating with wizard, if you try and modify the
sources to be "CreateWindow", not (e.eg) "xCreateWindow", error
messages follows.

Now I had #undef:ed CreateWindow, but it still gives me error
error C2059: syntax error : 'constant'
on a header file which the compiler generates, on the last line of
this clip:

CLIP2 -->
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE
CreateWindow(
LONG LViewportRow,
LONG LViewportColumn,
LONG LViewportHeight,
LONG LViewportWidth,
LONG LWindowHeight,
LONG LWindowWidth) = 0;
CLIP2 <--

-Esko

eskomk

unread,
Jun 6, 2008, 10:05:13 AM6/6/08
to
On Jun 5, 2:24 pm, eskomk <esko.huja...@gmail.com> wrote:
> On Jun 4, 2:09 pm, "Maxim S. Shatskih" <ma...@storagecraft.com> wrote:
>
>
>
> > Correct, this is a macro defined to CreateWindowA or CreateWindowW
>
> > Why is this bad?
>
> > --
> > Maxim Shatskih, Windows DDK MVP
> > StorageCraft Corporation
> > ma...@storagecraft.comhttp://www.storagecraft.com
>
> > "eskomk" <esko.huja...@gmail.com> wrote in message
>
> >news:0877a2c3-f20b-484f...@e53g2000hsa.googlegroups.com...
>
> > > Hi,
>
> > > How can I solve this problem:
> > > MS VisualStudio C++ thinks that CreateWindow is a macro and tries to
> > > expand it.
>
> > > It seems that this is a well-known problem, however I have not found
> > > any applicable solution.
>
> > > -Esko
>
> This clip fromhttp://www.wincor-nixdorf.com/internet/cae/servlet/contentblob/70232/...

Problem solved!

In translation unit that #includes compiler generated header which
has
CreateWindow hassle (#included windows.h):
-#include windows.h
-#undef CreateWindow
-#include compiler generated header


0 new messages