eclipse-iceoryx / iceoryx

Eclipse iceoryx™ - true zero-copy inter-process-communication
https://iceoryx.io
Apache License 2.0
1.6k stars 373 forks source link

Please put a notice in Windows platform section that header platform_correction.hpp might cause compile errors #1788

Open wukongiii opened 1 year ago

wukongiii commented 1 year ago

Brief feature description

Please put a notice in Windows platform section of the overview page, that headersplatform_correction.hpp might cause compile errors

Detailed information

I'm trying to use this great project on Windows platform, I was tring to turn my design to real code, strange compile erros occur. If I remove all IOX headers, the errors disappear. I googled those errors, at the beginning it seems like Winsock2.h not being properly included at the top of Windows.h, I tried this approach to every header that includes Windows.h, but it doesn't work. Then, I have to extract every header to find out which one causes the errors, and finally I found platform_correction.hpp, sure I read the notice that below license section in this header, but before that, I got no clue at all. So I think maybe you great guys can put some words about how to correctly put the header in the position.

elfenpiff commented 1 year ago

@wukongiii Thanks for the hint. I would add this also maybe to our FAQ section. Could you please post the compile failure you received? And how exactly did the error occur - under normal circumstances you shouldn't be in contact with the platform_correction.hpp? Or did you have to include the windows headers manually for your project since you were using them for something else?

The thing with the platform_correction.hpp is that is has to be always the last header which has to be included since it undo's and undefines the macros that windows introduces which cause a problem in platform independent C/C++ code.

wukongiii commented 1 year ago

@elfenpiff Thank you for your quick response! Since it's not easy to show you those errors by using my project structure, so I tried to reproduce this by using an empty project and some essential headers:

  1. Visual Studio 2022
  2. Create a console application
  3. C++ 17
  4. Add the include directory to the project
  5. add 2 headers :

    include

    include "iceoryx_posh/runtime/posh_runtime.hpp"

In my case the whole thing is like this:

#include <iostream>
#include <Shlwapi.h>
#include "iceoryx_posh/runtime/posh_runtime.hpp"
int main()
{
    std::cout << "Hello World!\n";
}

Build this projcet, you will get a lot of compile errors.

image That's why I was mislead to winsock2.h at the beginning.

elfenpiff commented 1 year ago

@wukongiii Thank you! This is actually very helpful. It originates in our iceoryx_platform where we provide structs for low level system constructs in a uniform manner. In this case we provided sockaddr_in etc. since it was not present at that time or was defined differently.

We have this on our radar and the idea is to add to all those things an iox_ prefix which should avoid such clashes. But now that you encountered the issue we have to start working on this earlier than expected.