Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Disabling language extensions in MSVC causes errors in 1.6  (Read 7914 times)

0 Members and 1 Guest are viewing this topic.

Floomi

  • Newbie
  • *
  • Posts: 16
    • View Profile
Disabling language extensions in MSVC causes errors in 1.6
« on: August 14, 2010, 07:59:24 pm »
Hi,

I've recently disabled MSVC language extensions for my project in an attempt to make the portability nightmare a little easier on my future self. Unfortunately this is throwing up a bunch of errors in Windows headers (trimmed the guff at the beginning for readability):

Code: [Select]
1> winnt.h(477) : error C2467: illegal declaration of anonymous 'struct'
1> winnt.h(495) : error C2467: illegal declaration of anonymous 'struct'
1> winnt.h(7723) : error C2467: illegal declaration of anonymous 'struct'
1> winnt.h(7732) : error C2467: illegal declaration of anonymous 'struct'
1> winnt.h(8248) : error C2467: illegal declaration of anonymous 'struct'
1> winnt.h(9066) : error C2133: '_EVENTSFORLOGFILE::pEventLogRecords' : unknown size
1> winnt.h(9072) : error C2133: '_PACKEDEVENTINFO::ulOffsets' : unknown size
1> winbase.h(232) : error C2467: illegal declaration of anonymous 'struct'
1> winbase.h(558) : error C2467: illegal declaration of anonymous 'struct'
1> wingdi.h(1893) : error C2467: illegal declaration of anonymous 'struct'
1> wingdi.h(1899) : error C2467: illegal declaration of anonymous 'struct'
1> wingdi.h(1947) : error C2467: illegal declaration of anonymous 'struct'
1> wingdi.h(1953) : error C2467: illegal declaration of anonymous 'struct'
1> winreg.h(113) : error C2146: syntax error : missing ';' before identifier 'QUERYHANDLER'
1> winreg.h(114) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(116) : error C2143: syntax error : missing ';' before '*'
1> winreg.h(116) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(116) : error C2365: 'QUERYHANDLER' : redefinition; previous definition was 'function'
1>         winreg.h(113) : see declaration of 'QUERYHANDLER'
1> winreg.h(116) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(119) : error C2146: syntax error : missing ';' before identifier 'pi_R0_1val'
1> winreg.h(119) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(119) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(120) : error C2146: syntax error : missing ';' before identifier 'pi_R0_allvals'
1> winreg.h(120) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(120) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(121) : error C2146: syntax error : missing ';' before identifier 'pi_R3_1val'
1> winreg.h(121) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(121) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(122) : error C2146: syntax error : missing ';' before identifier 'pi_R3_allvals'
1> winreg.h(122) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1> winreg.h(122) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


Turning on /showIncludes tells me that it's SFML/System/Win32/Mutex.hpp that's responsible for pulling it in (the exact tree is Mutex.hpp -> windows.h -> windef.h -> winnt.h).

I see that SFML 2.0 uses the pImpl idiom to get round this. Which is great, except that I'm on 1.6 :lol: Two questions, then:
1. Is 2.0 anywhere close to release, or at least some kind of usable beta?
2. Has anyone got any tips on getting this to work on 1.6?

Cheers!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Disabling language extensions in MSVC causes errors in 1.6
« Reply #1 on: August 14, 2010, 08:16:06 pm »
Quote
1. Is 2.0 anywhere close to release, or at least some kind of usable beta?

Not close to release, but usable yes. You can get the latest snapshot and compile it.

Quote
2. Has anyone got any tips on getting this to work on 1.6?

Don't know if it's true, but...
http://cboard.cprogramming.com/windows-programming/105719-errors-including-windows-h.html#post776204
Laurent Gomila - SFML developer

Floomi

  • Newbie
  • *
  • Posts: 16
    • View Profile
Disabling language extensions in MSVC causes errors in 1.6
« Reply #2 on: August 14, 2010, 08:21:50 pm »
Quote from: "Laurent"
Quote
2. Has anyone got any tips on getting this to work on 1.6?

Don't know if it's true, but...
http://cboard.cprogramming.com/windows-programming/105719-errors-including-windows-h.html#post776204

Interesting, I'll take a look at that. Apparently the very latest (Win7) SDK doesn't play nicely with VS2005, which is what I'm on, but I'll try the Server 2008 one and see if that helps any. Thanks!

Floomi

  • Newbie
  • *
  • Posts: 16
    • View Profile
Disabling language extensions in MSVC causes errors in 1.6
« Reply #3 on: August 14, 2010, 11:36:40 pm »
Good news! I couldn't get the latest Windows SDK, because I'm on VS2005 and the Win7 one doesn't support it. But I downloaded the Windows Server 2008 SDK, pointed my VC++ Directories to the new location, and hurrah! It builds with language extensions disabled :D

Thanks for the tip, it was right on the money :)

Floomi

  • Newbie
  • *
  • Posts: 16
    • View Profile
Disabling language extensions in MSVC causes errors in 1.6
« Reply #4 on: September 30, 2010, 11:43:45 pm »
Apologies for the thread necromancy, but it's related so I figured I might as well.

I've just #included <SFML/Network.hpp> in my project. As well as a bunch of C4251 warnings (which I see in 2.0 you've just #pragma'd out, so I'll do the same locally), I am also getting this:

Code: [Select]
1>C:\Program Files\Microsoft SDKs\Windows\v6.1\include\ws2def.h(567) : error C2467: illegal declaration of anonymous 'struct'

The include tree that gets me there is as follows:

Code: [Select]
SFML/Network.hpp
SFML/Network/Ftp.hpp
SFML/Network/SocketTCP.hpp
SFML/Network/SocketHelper.hpp
SFML/Network/Win32/SocketHelper.hpp
winsock2.h
ws2def.h


Once again, if I disable language extensions the error goes away. I'm on VS2005 so I can't upgrade my Windows SDK any further than the 6.1 I'm already on. And Google turns up nothing of use at all, oddly enough.

Am I stuffed?

Canadadry

  • Hero Member
  • *****
  • Posts: 1081
    • View Profile
Disabling language extensions in MSVC causes errors in 1.6
« Reply #5 on: October 01, 2010, 12:00:58 am »
Did you have some other include ? Could you switch them?

Floomi

  • Newbie
  • *
  • Posts: 16
    • View Profile
Disabling language extensions in MSVC causes errors in 1.6
« Reply #6 on: October 01, 2010, 12:09:59 am »
I'm not including any Windows headers in my project myself. The list of external includes I'm using, in order, are:

Code: [Select]
<GL/glew.h> - OpenGL extension handler
<SFML/Window.hpp>
<SFML/System/Clock.hpp>
<SFML/Graphics.hpp>
<SFML/Network.hpp>


Shuffling around the include order of these doesn't get me anywhere. I get the same errors (and some extra C4251 warnings thrown in for good measure).

edit:\ I've just checked and I can reproduce the issue simply by including SFML/Network.hpp in a single-file C++ project:

Code: [Select]
#include <iostream>
#include <SFML/Network.hpp>

int main(int argc, char **argv)
{
std::cout << "Hello, world!" << std::endl;
return 0;
}


Gives me the same error with language extensions disabled.

Floomi

  • Newbie
  • *
  • Posts: 16
    • View Profile
Disabling language extensions in MSVC causes errors in 1.6
« Reply #7 on: October 03, 2010, 06:00:30 pm »
To follow up on this - it's an issue with the MS headers. The latest SDK (Win7 7.1) is even worse than 6.1 (Server 2008) - the only issue I've had with SFML 1.6 is the network package (although I've not tried the Audio package yet).

I'm going to be creating a separate project for network stuff anyway, so I'll wrap SFML's functionality in that; then I'll only have to work with language extensions disabled in that project and not the others.

 

anything