haskell-opengl / OpenGL

Haskell bindings to OpenGL
http://www.haskell.org/haskellwiki/OpenGL
BSD 3-Clause "New" or "Revised" License
147 stars 26 forks source link

Building OpenGL emits tons of warnings on Win7 x86-64 GHC 7.6.1 #28

Closed ghost closed 11 years ago

ghost commented 11 years ago

The build is still successful. The issue is that the FFI bindings use the stdcall convention, but this convention doesn't exist on x85-64 windows. The solution is to export the bindings with the ccall convention for 64-bit windows platforms.

Alternatively, these warnings could be suppressed because there is exactly one calling convention on this platform anyway.

I'm not sure which solution is better.

svenpanne commented 11 years ago

OpenGLRaw.cabal contains the lines:

if os(windows) && flag(UseNativeWindowsLibraries)
   cpp-options: "-DCALLCONV=stdcall"
   cc-options: "-DUSE_WGLGETPROCADDRESS"
   extra-libraries: opengl32

Fixing this would be trivial if we could somehow detect that we are on a 64bit Windows platform. Can we do this somehow? Cabal experts to the rescue!

GLURaw.cabal and GLUT.cabal contain similar lines, BTW, and should be fixed similarly.

shelarcy commented 11 years ago

Cabal could detect architechture by using arch condition.

And 32 bit Windows' arch is i386.

I think we should just add three lines for fixing this problem:

if os(windows) && flag(UseNativeWindowsLibraries)
  if arch(i386)
    cpp-options: "-DCALLCONV=stdcall"
  else
    cpp-options: "-DCALLCONV=ccall"
  cc-options: "-DUSE_WGLGETPROCADDRESS"
  extra-libraries: opengl32
svenpanne commented 11 years ago

Those lines seem to make sense, I think I'll try them when I am back at a Windows box.

One question regarding 32bit/64bit Windows executables: 32bit executables exclusively call 32bit DLLs, and 64bit executables exclusively call 64bit DLLs, correct? Or put another way: It never happens that e.g. and executable calls a 64bit OpenGL DLL and uses a 32bit GLUT DLL at the same time, correct? I really hope that this is the case, otherwise I don't know how we should handle the calling convention correctly.

svenpanne commented 11 years ago

I've fixed this as suggested above for the OpenGLRaw, GLURaw and GLUT packages. Hmmm, probably I should do something similar for my OpenAL/ALUT package, too...