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

Author Topic: Compatibility with Windows API  (Read 2368 times)

0 Members and 2 Guests are viewing this topic.

svrtgujbhk

  • Newbie
  • *
  • Posts: 20
    • View Profile
Compatibility with Windows API
« on: August 11, 2011, 03:37:31 pm »
I wanted to use SFML's networking module, but it seems there are some compatibility issues with WinAPI.

The first issue, which I guess you know about, is that you must include <SFML/Network.hpp> before <windows.h> or it won't compile (some symbols are redefined).

However, if you include SFML first, the functions in the WinAPI header are no longer available. I tried to use ShellExecute, for example, and compiler cannot find the function declared anywhere.

Is there a way to solve this?
Or is there a way to run shell commands from SFML?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility with Windows API
« Reply #1 on: August 11, 2011, 03:46:24 pm »
Encapsulate the WinAPI calls in a separate translation unit, where you only include <Windows.h>?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Compatibility with Windows API
« Reply #2 on: August 11, 2011, 03:59:39 pm »
SFML defines the WIN32_LEAN_AND_MEAN macro, which is apparently the reason why ShellExecute is no longer defined if you include Network.hpp first.

So Nexus solution is the only one with SFML 1.6. With SFML 2 however, it works fine if you include Network.hpp after <windows.h>.

But I can probably remove WIN32_LEAN_AND_MEAN, all it does is to speed up compilation of SFML a little bit, it has no impact on libraries size or performances. It should work if you simply remove it from your SFML/Config.hpp (as a quick and dirty solution).
Laurent Gomila - SFML developer

svrtgujbhk

  • Newbie
  • *
  • Posts: 20
    • View Profile
Compatibility with Windows API
« Reply #3 on: August 11, 2011, 04:43:25 pm »
Thank you two for your help.