[opensource-dev] [SOLVED] Re: Compilation issues under MSVC2010: Windows guru help *badly* needed !

Henri Beauchamp sldev at free.fr
Sun Jul 29 06:11:28 PDT 2012


Problem solved !...

Man, what a sh*tty, Mickey Mouse OS Windoze (or "Windaube", in French,
for puns amateurs) can be !!!!... Its UTTER stupidity and hackiness
NEVER cease to amaze me !

The reasons for all my troubles were that:

- windows.h contains a "#pragam once" directive (instead of standard,
  robust and flawless #ifndef _HEADER_NAME_ / #define _HEADER_NAME_ /
  ... header here ... / #endif guards), which means that the
  pre-processor will *never* even *try* to include twice that header
  in nested header invocations.

- Somehow (but I didn't yet figured out it all: to be frank, at this
  point I don't really care any more...), #define WIN32_LEAN_AND_MEAN
  leads the pre-processor to only include the sub-headers (included
  from windows.h) that contain definitions used in the file calling
  the "#include <windows.h>" (and beacuse of the #pragma once, if
  another, nested file includes this file and contains other
  definitions requiring sub-headers that have been skipped the first
  time, it is f*cked up !).

- In v1.26.4.23 and v1.26.5.1 I added support for private memory pools,
  but in a more complete way than in LL's viewer (i.e. proper memory
  usage functions where added for Linux and MacOS-X in llsys.cpp to be
  used by the private pools manager in llmemory.cpp), and this lead me
  to add an '#include "sys.h"' into llmemory.h. And... llsys.h itself
  already contains an #include <windows.h>...

- In llwindow.cpp, the headers where included as follow:
  
  #include "linden_common.h"
  #include "llwindowheadless.h"

  #if LL_MESA_HEADLESS
  #include "llwindowmesaheadless.h"
  #elif LL_SDL
  #include "llwindowsdl.h"
  #elif LL_WINDOWS
  #include "llwindowwin32.h"        <-- With the problem arising here
  #elif LL_DARWIN
  #include "llwindowmacosx.h"
  #endif

  ...and it comes out that llwindowheadless.h was itself including
  llmemory.h, which was including (due to my modifications) sys.h,
  which was including windows.h. Then when llwindowwin32.h was
  trying to include windows.h in its turn (or winuser.h, after I
  tried adding it to solve the issue), it failed because of the
  combined effect of #pragma once and #define WIN32_LEAN_AND_MEAN.

The solution was to reorder the includes in llwindow.cpp to read:

  #include "linden_common.h"

  #if LL_MESA_HEADLESS
  #include "llwindowmesaheadless.h"
  #elif LL_SDL
  #include "llwindowsdl.h"
  #elif LL_WINDOWS
  #include "llwindowwin32.h"
  #elif LL_DARWIN
  #include "llwindowmacosx.h"
  #endif

  // SHITTY MSVC INCLUDE ISSUES WARNING:
  // include llwindowheadless.h* AFTER* llwindowwin32.h, else bad
  // things happen at compilation time !
  #include "llwindowheadless.h"

Note that I'm still lucky that llwindowheadless.h doesn't need
definitions from sub-includes of windows.h that are skipped by
the latter when it is included by llwindowwin32.h (if you still
can follow all the indirections in this reasonning, lol !)...

To prevent such issues in the future, I suggest that the viewer
sources are ammended so that #include <windows.h> is *NEVER*
done from header files, but only from the *.cpp files using
headers files that require windows.h's inclusion; this may
lead to have to manually add a few includes (windows.h
sub-includes) in the *.cpp files (that might be skipped by
windows.h because of the #define WIN32_LEAN_AND_MEAN if some
definitions are used in the *.h file and not in the *.cpp
file), but at least those includes won't be impacted in case of
nesting by the "#pragma once" that hit me hard here, since even:
  #undef NOUSER
  #undef NOMSG
  #undef _WINUSER_
  #include <WinUser.h>
could not get past it and prevented the needed winuser.h
definitions to be included at all !...

I can't provide a patch, since LL won't use it (not having given up
my privacy to fill up their stupid "contribution agreement" form and
stuff...), but you may consider this info as LGPL (or anything
fancying you) and produce the patch yourself.

Henri.

------------
On Sun, 29 Jul 2012 10:40:02 +0200, I wrote:

> Greetings, folks !
> 
> I just ran into a problem that lets me quite clueless: I recently migrated
> the Cool VL Viewer build system from VS2005 to VS2010 and succeeded, two
> weeks ago, to compile v1.26.5.0 under VS2010.
> 
> This week, I was about to make two new releases (v1.26.4.23 which is basically
> the same as v1.26.5.0 with just a few things added) and v1.26.5.1 which is the
> firts release with the v3.3.4 renderer backported (working just fine under
> Linux).
> 
> But then I came around an issue dealing with Windows headers inclusion that
> I just can't figure out. When compiling (either v1.26.4.23 or v1.26.5.1),
> VS2010 fails for the llwindow library, with the following error (sources
> path edited to linden\ for clarity):
> 
> llwindow.cpp
> linden\indra\llwindow\llwindowwin32.h(45): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(45): error C2143: syntax error : missing ',' before '&'
> linden\indra\llwindow\llwindowwin32.h(146): error C2061: syntax error : identifier 'COMPOSITIONFORM'
> linden\indra\llwindow\llwindowwin32.h(147): error C2061: syntax error : identifier 'CANDIDATEFORM'
> linden\indra\llwindow\llwindowwin32.h(148): error C2061: syntax error : identifier 'IMECHARPOSITION'
> linden\indra\llwindow\llwindowwin32.h(150): error C2061: syntax error : identifier 'RECONVERTSTRING'
> linden\indra\llwindow\llwindowwin32.h(177): error C2146: syntax error : missing ';' before identifier 'mWndProc'
> linden\indra\llwindow\llwindowwin32.h(177): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(177): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(237): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(237): error C2143: syntax error : missing ',' before '&'
> 
> COMPOSITIONFORM & Co pertain to Imm.h and the errors around lines 45 and 177+
> are related to undefined MSG and WNDPROC types (that seem ro pertain to
> WinUser.h).
> 
> The weird thing is that I didn't change a single thing in v1.4.26.23 in
> llwindows/, neither in the cmake files when compared to v1.26.5.0 that
> (still) compiles just fine !!!
> 
> I checked the Windows headers inclusion and they seem just fine, with,
> in llwindowwin32.h:
> 
> ------------
> #ifndef LL_LLWINDOWWIN32_H
> #define LL_LLWINDOWWIN32_H
> 
> // Limit Windows API to small and manageable set.
> #define WIN32_LEAN_AND_MEAN
> #include <winsock2.h>
> #include <windows.h>
> 
> .../...
> ------------
> 
> Adding #include <Imm.h> after #include <windows.h> in llwindowwin32.h
> allows to get rid of the undefined COMPOSITIONFORM ... RECONVERTSTRING
> types, but adding #include <WinUser.h> doesn't solve the issue with
> MSG and WNDPROC not being defined, even if I use:
> 
> ------------
> #ifndef LL_LLWINDOWWIN32_H
> #define LL_LLWINDOWWIN32_H
> 
> // Limit Windows API to small and manageable set.
> #define WIN32_LEAN_AND_MEAN
> #include <winsock2.h>
> #include <windows.h>
> #include <Imm.h>
> #undef NOUSER
> #undef NOMSG
> #undef _WINUSER_
> #include <WinUser.h>
> ------------
> 
> I always get:
> 
> llwindow.cpp
> linden\indra\llwindow\llwindowwin32.h(50): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(50): error C2143: syntax error : missing ',' before '&'
> linden\indra\llwindow\llwindowwin32.h(182): error C2146: syntax error : missing ';' before identifier 'mWndProc'
> linden\indra\llwindow\llwindowwin32.h(182): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(182): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(242): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
> linden\indra\llwindow\llwindowwin32.h(242): error C2143: syntax error : missing ',' before '&'
> 
> What is totally flabbergasting is that between v1.26.5.0 (which compiles
> fine) and v1.26.4.23, the diff is only 300Kb and NOTHING in it touches
> the cmake files neither the llwindow/ files !!!
> Plus, llwindowwin32.cpp (which also needs and includes llwindowwin32.h)
> compiles just fine, unlike llwindow.cpp (and yes, I also tried to add
> the same Windows includes in the latter than in the former, to no avail).
> 
> Finally, I tried on two different build systems (a WinXP SP3 virtual
> machine and a genuine (non emulated) Windows 7 Ultimate system), to no
> avail (not a build system issue, apparenetly, especially since v1.26.5.0
> still compiles just fine).
> 
> Any clue of what is going wrong with this sh*tty VS2010 ?
> 
> Many thanks in advance !
> 
> Henri.
> 


More information about the opensource-dev mailing list